My code:
<?php
$file="./Speed10.txt";
$document=file_get_contents($file);
$rows = explode ('(', $document);
$a[$r][$c];
for($r=0; $r<9103; $r++){ //1903 rows in text file
$a[$r][$c]; // Array declared here - doesnt solve problem
for($c=0; $c<103; $c++){
//$a[$r][$c] = rand();
// print_r($a[$r][$c]);
}
}
foreach ($rows as $ri => $row) {
$a[$ri][$c] = explode (';', $row);
//XXXXXXXXXXXXX
}
print_r($a[1][$c]); // NOT PRINTING*
?>
I have a 2D array as you can see above, it divides a text file into rows and columns. That part works perfectly, but I try to print out all the cells of one row, it isn't printing.
However, if I move the print_r line to where the X's are, it works (although its being printed out in a loop). Sounds like a scope problem to me but I can't figure out what. I tried initialising the array as a global variable but that didn't fix it.