How can I get the total number of rows that are in a CSV file using PHP? I'm using this method but can get it to work properly.
if (($fp = fopen("test.csv", "r")) !== FALSE) {
while (($record = fgetcsv($fp)) !== FALSE) {
$row++;
}
echo $row;
}
CSV rows are separated by line breaks. Therefore, split the rows by line breaks, and you will get an array of rows, which is countable.
Try
In case you are getting the file from a form
Works like charm!!!!!!!!!!!!!!!!!!