in this code below , i am trying to put specific file from directory in an array(right now i have 2 file) and then use one file in function to put the text of file into database table. But file_get_contents is somehow enable to read text file from that array which is formed from directory? please help…
[<?php
$con=mysqli_connect(“localhost”,””,””,”test”);
if (mysqli_connect_errno($con))
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
function FillinfoTable()
{
$dir = “/
$files1 = scandir($dir);
$file=preg_grep(“/additional(w+)/”,$files1);
print_r($file);
$file_not=preg_grep(“/additional(w+)/”,$files1,PREG_GREP_INVERT);
print_r($file_not);
$file_content=file_get_contents(‘$file_not’);
$file_content=explode(PHP_EOL,$file_content);
for($i=0;$i<count($file_content)-1;$i++){
$exploded_content=explode(“: “,$file_content[$i]);
$q=mysqli_query($con,”INSERT INTO ‘g1’ (NAME, DETAIL) values(‘$exploded_content[0]’,’$exploded_content[1]’)”);
}}
FillinfoTable();
mysqli_close($con);
?>]