My code is below:
$total_array = array("");
function text_to_array(){
$file = fopen("data1.txt", "r") or die("File is inaccessible.");
$array = array("");
if ($file){
$counter = 0;
while (! feof($file))
{
$array[$counter] = fgets($file);
$counter++;
}
fclose($file);
}
else{
echo "File unsuccessful. \n";
}
array_push($total_array, $array);
}
I'm currently studying the basics of PHP and my question is, how come it displays an error even though I'm pushing the $array into $total_array, that of which is an array? I'm trying to create a 2d array.