.Darkman Posted April 23, 2007 Share Posted April 23, 2007 Hello Everybody, I am planning to make a site where users can enter a video's url (youtube and such) and the video will be embedded into our site. So i need to know how to strip a part of the url. For eg, A Youtube's url is : And the embed code is : <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/hdf4GeT4ELA"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/hdf4GeT4ELA" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> ' I want to separate hdf4GeT4ELA from the URL so that i can use it in the Embed code. How shall i do is irrespective of whether it is or That may be pretty simpler. There is another site called "Grouper" which i am going to allow. Video Url is http://grouper.com/video/MediaDetails.aspx?id=1820852&ml=fpl%3d38714%26fx%3d And the Embed code is <embed allowScriptAccess="never" allowFullScreen="true" src="http://grouper.com/mtg/mtgPlayer.swf?v=1.7" width="400" height="325" quality="high" scale="noScale" FlashVars="ap=0&mu=0&rf=-1&vfver=8&extid=-1&extsite=-1&id=1820852&ml=fpl%3d38714%26fx%3d" wmode="window" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed> How do i remove 1820852 and fpl%3d38714%26fx%3d from this URL. Thanks a lot for any help. Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/ Share on other sites More sharing options...
Guest prozente Posted April 23, 2007 Share Posted April 23, 2007 On the parse_str page it explains one of the many ways to do this http://us2.php.net/manual/en/function.parse-str.php Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235674 Share on other sites More sharing options...
rcorlew Posted April 23, 2007 Share Posted April 23, 2007 $queryString = $_SERVER['QUERY_STRING']; Will set everything after the question mark. You can display it like this: http://grouper.com/video/MediaDetails.aspx?$querystring I don't really understand what you are trying to do, but that is the path you need to be headed down. Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235675 Share on other sites More sharing options...
.Darkman Posted April 23, 2007 Author Share Posted April 23, 2007 I don't really understand what you are trying to do What i want to do is that when a user enter the url in a field and hit submit button, i want the Embed code to be saved in the database. Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235679 Share on other sites More sharing options...
Guest prozente Posted April 23, 2007 Share Posted April 23, 2007 You could retrieve the page then use a regular expression to get the code, but this is against youtubes Terms of Use Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235680 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 23, 2007 Share Posted April 23, 2007 Get the url, then use a regex to parse the code out of the url like so: $url = "http://www.youtube.com/watch?v=hdf4GeT4ELA"; $url .= "END"; // This is so you can end the regexp efficiently preg_match("|v=(.+?)END|", $url, $match); $code = $match[1]; Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235732 Share on other sites More sharing options...
.Darkman Posted April 23, 2007 Author Share Posted April 23, 2007 Thanks to everyone who replied. I have figured it out. I separate the Query part using parse_url and then use parse_str to separate the values. Thanks, Link to comment https://forums.phpfreaks.com/topic/48209-solved-stripping-a-part-of-the-url/#findComment-235808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.