Error when trying to access a 2d Array in PHP -


i have written couple pages , function turn .csv file array, after using array access , use data. of code in place , works stuck trying access fields want.

the code create array looks this:

//code accepting , checking uploaded file if($ext === 'csv'){         if(($handle = fopen($tmpname, 'r')) !== false) {               set_time_limit(0);              //index             $row = 0;              while(($data = fgetcsv($handle, 1000, ',')) !== false) {                 // number of fields in csv                 $num = count($data);                 /*echo "<p> $num fields in line $row: <br /></p>\n";*/                  // values csv                 $csv[$row]['row1'] = $data[0];                 $csv[$row]['row2'] = $data[1];                 $csv[$row]['row3'] = $data[2];                 $csv[$row]['row4'] = $data[3];                  //increment                  $row++;             }              print_array($csv[1][0]);             fclose($handle);         }     } 

and when call print_array($csv[1]; result is:

array (     [row1] => dataone     [row1] => datatwo     [row1] => datathree     [row1] => datafour )  

but when call print_array($csv[1][1]); error: notice: undefined offset: 1 on line *and on*

everything have read makes seem should work. can't figure out how access need. appreciated.

try check how many elements array have looks me read first line , array length 1.

echo("array count: ".count($csv)); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -