note 80385 deleted from function.array-search by levim

From: Date: Mon, 24 Feb 2014 22:41:54 +0000
Subject: note 80385 deleted from function.array-search by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198651@lists.php.net to get a copy of this message
Note Submitter: steev at anticulture dot co dot uk ---- Just adding my two penneth to someone else's script from below. If you need to easily index your csv use this slightly modified script to parse a csv file into an associative array 2d, indexed by the first column value <?php function buildStock($File) { $handle = fopen($File, "r"); $fields = fgetcsv($handle, 1000, ","); while($data = fgetcsv($handle, 1000, ",")) { $detail[] = $data; } echo "details"; var_dump($detail); echo "<br />"; $x = 0; $y = 0; foreach($detail as $i) { foreach($fields as $z) { //original code //$stock[$x][$z] = $i[$y]; $stock[$i['0']][$z] = $i[$y]; $y++; } $y = 0; $x++; } return $stock; } var_dump(buildStock("conf.csv")); ?>

« previous php.notes (#198651) next »