Check out my twitter script by CMXads
Goth and Gore Gifts Shop right now or else! | Sharp Stuff Switchblades Icepicks and german knives | Till death do us part Axels New Music releases | Viking gear Gear Gifts and Apparel |
here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.
parse a csv file associative array delimited file data return using fgetscsv indexed by the first row values
fgetscsv delimited csv file array associative
<?php
function csv_to_array($filename='', $delimiter=';')
{
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
$header = NULL;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE)
{
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
{
if(!$header)
$header = $row;
else
$data[] = array_combine($header, $row);
}
fclose($handle);
}
return $data;
}
echo '<pre>';
//can add as many column names you like see format
var_dump(csv_to_array('cart-data2.txt'));
echo '</pre>';
exit;
?>