Use .csv as data source with PHP -
Use .csv as data source with PHP -
with php want pull in text comma separated csv file (my array) on server. dependent on text (title) pulled page variable.
i.e.
<div><?php echo $item->title;?> <div>prices £[php cost here]</div>
where 'title' in echo (above) spain.
so csv have:
spain, 250 france, 350 germany, 150
spain beingness 'title' , '250' beingness [php cost here] want pull in.
so if kingdom of spain 'title' beingness pulled in, grab cost of 250.
i.e.
spain prices £250
hope makes sense... thanks
just example. assumning have file info called pricelist.csv
.
$pricelist = array(); if (($handle = fopen("pricelist.csv", "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { $pricelist[] = $data; } fclose($handle); } echo '<pre>'; print_r($pricelist); echo '</pre>';
will give output:
array ( [0] => array ( [0] => kingdom of spain [1] => 250 ) [1] => array ( [0] => french republic [1] => 350 ) [2] => array ( [0] => federal republic of germany [1] => 150 ) )
now able utilize array data.
php csv
Comments
Post a Comment