Jump to content

Loop through CSV


wiggst3r

Recommended Posts

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 resutls results at 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?

Link to comment
Share on other sites

<?php

$handle = fopen("results.csv", "r");
$race_time = 13; // column number of total time
$mob_num = 10;// column number of mob num
$url1 = '<a href="http://www.example.com">www.www.example.com</a> ';
$url2 = '<a href="http://www.example.com">http://www.example.com</a> ';

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
echo "Congratulations on finishing the race, your time was " . $data[$race_time] . " Full race results at " . $url1 . $url2 .  '<br><br>';
}
fclose($handle);

?>

 

I have this so far, that loops through the results and displays each row to the screen.

I have a column, which will have UK mobile phone numbers in (e.g. 07777777777), one number per racer.

 

I'll need to validate this number and make sure it is in the right format, and then drop the '0' and add +44 to the start, so that the

sms(AQL) API can send the sms to the correct recipient. Which I'm not sure how I'd validate the mobile number.

 

I have the sms function that I could post, If anyone is willing to help me with?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.