php - fgetcsv formatting individual cells -


this question has answer here:

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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -