PHP and CSV

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wiggst3r
Forum Newbie
Posts: 10
Joined: Wed Apr 09, 2008 10:59 am

PHP and CSV

Post 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?
madan koshti
Forum Commoner
Posts: 50
Joined: Fri Jun 06, 2008 4:25 am

Re: PHP and CSV

Post 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);
?>
Post Reply