Page 1 of 1

PHP and CSV

Posted: Mon Jun 09, 2008 5:49 am
by wiggst3r
Hi

I have a csv with 17 columns.

I'm only interested in 2 columns though, one is a 'TotalTime' column and the other is a MobileNumber(will be used to send an sms at a later time)

What I'm looking to do, is loop through each row and append the time to pre-defined string, such as:
Congratulations on completing the race, your time was 00:00:00 Full race results at http://www.example.com
For testing, I would like it to be outputted, in html to the screen (so i know it's working)

Any ideas how I could do this?

Re: PHP and CSV

Posted: Mon Jun 09, 2008 6:50 am
by madan koshti
Hi,

I hope you need this ???????

<?php
$handle = fopen("filename.csv", "r");
$tot_time = 2; // column number of total time
$mob_num = 10;// column number of mob num
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
echo "Congratulations on completing the race, your time was".$data[$tot_time]."Full race results at http://www.example.com";
}
fclose($handle);
?>