Online Forum To Support Coders With Technical Assistance - Read Write Execute

How to read csv file in php

Ankit Agrawal
Ankit Agrawal
Published on August 17, 2015 · 1 min read
<?php
$aCsv = "data.csv";
$aRows = array();
$aHandle = fopen($aCsv, 'r');
if($aHandle !== FALSE) {
	 while (($aData = fgetcsv($aHandle, 1000, ",")) !== FALSE)
	 {
	 	$aRows[] = $aData;
	 }
}

print_r($aRows);
?>
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article How to add new sidebar for my theme in wordpress Next Article → How to add a select box in cakephp ?