There are a few ways to read CSV files with PHP. I used to use the explode function to put each line into an array and then explode commas and use trim
There is a function for reading files in line-wise: file(), which also works on both linebreak types.
And the shortest method to read in the whole CSV file is:
$data = array_map("str_getcsv", file($filename));
Not sure what your $num = count() was about.
$num = count()