wiggst3r Posted June 9, 2008 Share Posted June 9, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/109378-loop-through-csv/ Share on other sites More sharing options...
MadTechie Posted June 9, 2008 Share Posted June 9, 2008 What do you have so far ? can you post your code.. Quote Link to comment https://forums.phpfreaks.com/topic/109378-loop-through-csv/#findComment-561034 Share on other sites More sharing options...
wiggst3r Posted June 9, 2008 Author Share Posted June 9, 2008 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/109378-loop-through-csv/#findComment-561103 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.