php question Write code to import an external file named clo
php question
Write code to import an external file named \'clonetrooperlist.csv\'. Retrieve and echo each line.
Solution
\"fgetcsv()\" method is used to parse a csv file line by line until we encounte EOF(end of file).
<?php
 $file_ptr = fopen(\"clonetrooperlist.csv\",\"r\");
 
 while(! feof($file_ptr))
   {
   print_r(fgetcsv($file_ptr));
   }
 
 fclose($file_ptr);
 ?>

