computer guy Posted March 26, 2009 Share Posted March 26, 2009 Hi everyone, Is there a way that I can extract the following etaRadio Ratings Dump – Current at 26/03/09<--The date DJ Joelstar 14 12 14 15 18 21 16 20.17<--These eight numbers (seperate) and the DJ name From a string like this etaRadio Ratings Dump – Current at 26/03/09 DJ Joelstar 14 12 14 15 18 21 16 20.17 DJ Ant 0 0 0 0 0 0 0 0.00 DJ Jaxon 18 16 14 19 21 14 17 21.89 DJ Chuckmeister85 19 21 24 32 24 18 23 29.61 DJ Pat4life 21 20 24 28 21 18 22 28.33 DJ JessieB 0 0 0 0 0 0 0 0.00 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/ Share on other sites More sharing options...
corbin Posted March 26, 2009 Share Posted March 26, 2009 explode By the way, the description of the PHPF Questions, Comments, Suggestions section: This is NOT a help forum! Discussions about our website should go here. Feature requests, compliments, complaints... whatever you want, just be nice Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794237 Share on other sites More sharing options...
computer guy Posted March 26, 2009 Author Share Posted March 26, 2009 Thank you Sorry I couldn't find where 2 ask a help related question. Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794245 Share on other sites More sharing options...
Daniel0 Posted March 26, 2009 Share Posted March 26, 2009 Uh... perhaps in "PHP Help", which is like 5 cm below this forum unless you have a gigantic monitor. How difficult is it to just look over all the boards? It'll take two minutes tops. Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794257 Share on other sites More sharing options...
computer guy Posted March 26, 2009 Author Share Posted March 26, 2009 I have a 15" monitor so I dont think that is the problem. Im sorry but I didn't see "PHP help". Thank you for moving the thread. Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794270 Share on other sites More sharing options...
POG1 Posted March 26, 2009 Share Posted March 26, 2009 Where is the date? :S Is this supposed to be the date? 19 21 24 32 24 18 23 29.61 Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794295 Share on other sites More sharing options...
computer guy Posted March 26, 2009 Author Share Posted March 26, 2009 etaRadio Ratings Dump – Current at 26/03/09<--The date That is the date. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794305 Share on other sites More sharing options...
sasa Posted March 26, 2009 Share Posted March 26, 2009 try <?php $test = 'etaRadio Ratings Dump – Current at 26/03/09 DJ Joelstar 14 12 14 15 18 21 16 20.17 DJ Ant 0 0 0 0 0 0 0 0.00 DJ Jaxon 18 16 14 19 21 14 17 21.89 DJ Chuckmeister85 19 21 24 32 24 18 23 29.61 DJ Pat4life 21 20 24 28 21 18 22 28.33 DJ JessieB 0 0 0 0 0 0 0 0.00'; preg_match('/Current at\s(\d+\/\d+\/\d+)/',$test,$date); echo $date[1],"<hr />\n"; preg_match_all('/(.*)\s+(([0-9]+ ){7}[0-9\.]+)/',$test,$numbers); $dj = $numbers[1]; foreach ($dj as $k => $v) $dj[$k] = trim($v); $num = $numbers[2]; foreach ($num as $k => $v) $num[$k] = explode(' ',trim($v)); $data = array_combine($dj, $num); echo '<pre>',print_r ($data),'</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794309 Share on other sites More sharing options...
computer guy Posted March 26, 2009 Author Share Posted March 26, 2009 Thank you sasa Quote Link to comment https://forums.phpfreaks.com/topic/151191-extracting-data-from-textstring/#findComment-794310 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.