php - fgetcsv formatting individual cells -
this question has answer here:
- how extract data csv file in php 6 answers
i have csv file data in it
date,title,description 01/05/2013,test,this test 03/05/2013,test2,this test i format news article html like
<article> <h3>$title</h3> <h6>posted on $date</h6> <p>$description</p> </article> <article> <h3>$title</h3> <h6>posted on $date</h6> <p>$description</p> </article> i each $line bit, not sure how rest of it. lots around tables, not can find.
can out please?
thanks neil
something should work
foreach ($csvdata $line) { vprintf( '<article><h3>%s</h3><h6>posted on %s</h6><p>%s</p>/article>', explode(',', $line) ); } edit based on @gordon comment, using fgetcsv
while (($line = fgetcsv($handle, 1000, ",")) !== false) { vprintf( '<article><h3>%s</h3><h6>posted on %s</h6><p>%s</p></article>', $line ); }
Comments
Post a Comment