tobykw13 Posted October 4, 2007 Share Posted October 4, 2007 I am relatively new to PHP and am having some trouble. I have seen some tutorials on how to retrieve a section of the current URL with php, but what I am trying to do is a little different. I need to be able to specify any myspace URL in a form and have the output be a section of that URL. For example: I input the following URL into a form field: http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=257367900 when the submit button is pressed the output should show: 257367900 I need it to be so that I can input any myspace url as such and the output will be everything after the "&friendid=" an example of something similar to what I am going for can be found here: http://www.bbzspace.com/overlay/link.php Not sure if this is very elementary or sounds stupid but as I said I am a novice at this so any help would be appreciated! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/71763-extracting-part-of-specified-url/ Share on other sites More sharing options...
corbin Posted October 4, 2007 Share Posted October 4, 2007 You could do it with regular expressions, exploding (or technically strpos too, but I'm gonna avoid that one): Regexp: $url = 'http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=257367900'; if(preg_match('/&friendid=([0-9]+)/', $url, $matches)) { print_r($matches); //matches[1] would be the friend id } Bleh I'm tired so I'm skipping the explode way ;p lol. Quote Link to comment https://forums.phpfreaks.com/topic/71763-extracting-part-of-specified-url/#findComment-361404 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.