I have an array like this
$a = scandir($dir)
It contains a list of folders in a directory. How can I store each element of the array as a new record in a database table? The only methods I have found so far convert the array to one long string.
I have tried
foreach($array as $item)
send each item to database
But I receive the error " Notice: Undefined variable"
Full Code
$dir = "/some/folder";
// Sort in ascending order
$a = scandir($dir);
$string_version = implode(',', $a);
$array = explode(' ', $string_version);
foreach($array as $item)
{
$dbcon="INSERT INTO $DBTable(Column) VALUES('$item')";
}
?>