devWhiz Posted April 14, 2011 Share Posted April 14, 2011 Is it possible to have create a function that would load a URL and then you could use explode to parse out the data it gives you from the function? like function GetData() { $data = file_get_contents('http://www.yahoo.com'); return($data); } $MSG = explode("<message>", 'GetData'); $MSG = explode("</", $MSG[1]); echo $MSG[0]; or would it be more efficient to just do this $data = file_get_contents('http://www.yahoo.com'); $MSG = explode("<message>", $data); $MSG = explode("</", $MSG[1]); What do I have to change to get the first method to work? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/233660-function-help/ Share on other sites More sharing options...
requinix Posted April 14, 2011 Share Posted April 14, 2011 1. Don't use explode(). Use regular expressions. 2. Actually, don't use regular expressions. Use DOM for HTML and SimpleXML for XML/XHTML. Quote Link to comment https://forums.phpfreaks.com/topic/233660-function-help/#findComment-1201367 Share on other sites More sharing options...
devWhiz Posted April 14, 2011 Author Share Posted April 14, 2011 Lol I'm a noob, I've been using explode to parse xml and anything else for the longest time.. Congrats on 600 posts btw So what should I do here? Quote Link to comment https://forums.phpfreaks.com/topic/233660-function-help/#findComment-1201372 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.