Your code is already correct.
$data
is multidimensional array, each element is an array itself. When you echo $data[1]
you are asking PHP to write a string representation of a more complex array variable, which PHP handles by outputting array
instead of its contents.
Instead, var_dump()
it to see what it contains.
var_dump($data);
A single value would be accessed via something like :
echo $data[1][0];
Edit after comment:
If the CSV contains only one value per row, access it directly via $row[0]
when appending to the output array in order to get it as a 1D array:
if (($handle = fopen("fullbox.csv", "r")) !== FALSE) {
while(($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
$data[] = $row[0];
}
}
// $data is now a 1D array.
var_dump($data);