Hi Guys!
Im trying to read a CSV file using PHP and output the data. When I upload the CSV, it only outputs the first line of data. Any idea why this may happen?
Here’s the code I am using:
$file_handle = fopen($_FILES['csv']['tmp_name'], "r");
while(!feof($file_handle)) {
$data = fgetcsv($file_handle, 10240);
$domain = $data[0];
$price = $data[1];
$currency = $data[2];
echo $domain."<br />";
}
Here’s the CSV I am using:
a-mortgage.com,4000,USD
a-one.com,3000,USD
a-online-pharmacy.com,2500,USD
a-perfect-world.com,600,USD
a-photo.com,1600,USD
a-plan.net,1300,USD
a-property.com,3000,USD
a-room.com,3500,USD
a-run-for-your-money.com,500,USD