pgrevents Posted May 5, 2009 Share Posted May 5, 2009 Again not to confident with php I am trying to get a specific part of a url for example http://www.pgrevents.co.uk/process/yvideo.php?catch=http://uk.video.yahoo.com/watch/5005027/13315673 I need to get the 5005027 Does anyone have any ideas? I tried looking for examples but I cant seem to get any thanks Paul Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/ Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 First, I would advice you to learn PHP basics if you don't know it already. I am not underestimating your abilities, but it would help you to understand my code. It's a basic *snippet*. It's not a full code so please do not badger me about it not working if you just copy and paste. <?php $catch = $_GET['catch']; preg_match('#watch/(\d+)/', $catch, $match); Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826692 Share on other sites More sharing options...
pgrevents Posted May 5, 2009 Author Share Posted May 5, 2009 i understand the basics and will look more into th code you have provided thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826702 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 First, I would advice you to learn PHP basics if you don't know it already. I am not underestimating your abilities, but it would help you to understand my code. It's a basic *snippet*. It's not a full code so please do not badger me about it not working if you just copy and paste. <?php $catch = $_GET['catch']; preg_match('#watch/(\d+)/', $catch, $match); Whoops, my mistake. <?php $catch = $_GET['catch']; preg_match('#watch/(\d+)/#', $catch, $match); I forgot the closing delimiter. I apologize. The above should be correct. Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826705 Share on other sites More sharing options...
pgrevents Posted May 5, 2009 Author Share Posted May 5, 2009 I have actualy been looking into this using parse_url here is an example <?php $catch = $_GET['catch']; print $catch; print "<br />"; ///GO GO GADGET print_r(parse_url($catch)); print "<br />"; echo parse_url($catch, PHP_URL_PATH); ?> which gives me an out put of; http://uk.video.yahoo.com/watch/5005027/13315673 Array ( [scheme] => http [host] => uk.video.yahoo.com [path] => /watch/5005027/13315673 ) -> this is using the last echo in the code = /watch/5005027/13315673 that is getting closer to what I am looking for. Am I on the right track? thanks Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826772 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 I'll take it that you don't like my idea. Fair enough. Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826792 Share on other sites More sharing options...
pgrevents Posted May 5, 2009 Author Share Posted May 5, 2009 sorry lol. i tried it but i didnt undestand it as it kept outputting = Array() or 1. and you said dont badger you so kept looking on php.net Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826793 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 That's not what I meant. It's just some people show less courtesy to people giving help that when I post snippets (not full code), they copy and pasted and then come back and say it doesn't work. <?php $catch = $_GET['catch']; preg_match('#/watch/(\d+)/#', $catch, $match); In that code, you would like to print_r($match) because it is an array. If you echo it, you'll get Array(). Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826796 Share on other sites More sharing options...
pgrevents Posted May 5, 2009 Author Share Posted May 5, 2009 oooohhhhh it worked thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826803 Share on other sites More sharing options...
pgrevents Posted May 5, 2009 Author Share Posted May 5, 2009 and I use array_pop($match); to grab that code yeeeeee Quote Link to comment https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826814 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.