Hello - I am new to php and was wondering if I am going about effectively or is there an easier way to go about this. I have a multidimensional array created from some data I pulled out of mysql Example of the array array[0] = 12345, 1, 5 array[1] = 56789, 2, 6 array[2] = 09876, 3, 7 The first numbers are product ids and the second and third are category ids. Here is how I extracted the values //While loop to spin through returned data while (($data = fgetcsv($handle, filesize($fileName), ",")) !== FALSE) { //count fields in array $num = count($data); for ($c=0; $c < $num; $c++) { if ($c == 0) { $productID = $data[$c]; }else { $categoryID = $data[$c]; } } PHP: Is this an efficient way of getting these values or is there an easier way? Thanks
I don't understand? You got data from a mysql table and saved it as comma separated values in a file? And then you read that file to get the values?
you need not store data in file from mysql. simply read it from mysql using queries and if you are facing performance issue, then let us know table structure and queries you are using so that we can help you optimize them.