prolinu Posted July 5, 2009 Share Posted July 5, 2009 My Programmer used this code to strip out characters expect the youtube ID in order to create the thumbnail picture of youtube video. For a youtube link like: src="http://www.youtube.com/watch?v=XrL5YIsUQu0" He used this code: $colony = explode("src=",$videoembed); $colonized = explode("/",$colony[1]); $colonizer = explode("\"",$colonized[4]); $coloni = explode("&",$colonizer[4]); $thumb_name = "http://img.youtube.com/vi/".$colonizer[0]."/default.jpg"; So that thumbnail image URL result will be http://img.youtube.com/vi/XrL5YIsUQu0/default.jpg Now Youtube has additional strings with src=link. I am not able to explode the addition strings by using above method. Now Youtube link look like this: src="http://www.youtube.com/watch?v=XrL5YIsUQu0&hl=en&fs=1&rel=0" How to strip out &hl=en&fs=1&rel=0 after the youtube video ID by using same above method? Now youtube thumbnail image link comes like this: http://img.youtube.com/vi/XrL5YIsUQu0&hl=en&fs=1&rel=0/default.jpg I want it as http://img.youtube.com/vi/XrL5YIsUQu0/default.jpg Your help will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/164840-php-explode-function-help/ Share on other sites More sharing options...
haku Posted July 5, 2009 Share Posted July 5, 2009 We're here to help people with code they have having troubles writing, not for writing the code for people. You can use the freelance section of the site for that. Or else you can have your developer come here and show us what he has already written, and we can help him with whatever problems he is having. Quote Link to comment https://forums.phpfreaks.com/topic/164840-php-explode-function-help/#findComment-869175 Share on other sites More sharing options...
prolinu Posted July 5, 2009 Author Share Posted July 5, 2009 I am seeking a help to fix this issue. The code was working once, now it has a error. So I came here to see if someone could help me to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/164840-php-explode-function-help/#findComment-869180 Share on other sites More sharing options...
haku Posted July 5, 2009 Share Posted July 5, 2009 Alright then. Explode the URL based first on the slashes, then explode the last key of the array by the ampersands (&). You will then have a couple arrays, which you can use to build the url you want. Quote Link to comment https://forums.phpfreaks.com/topic/164840-php-explode-function-help/#findComment-869185 Share on other sites More sharing options...
.josh Posted July 5, 2009 Share Posted July 5, 2009 $string = "http://img.youtube.com/vi/XrL5YIsUQu0&hl=en&fs=1&rel=0/default.jpg"; preg_match('~/([^&/]*)&~',$string,$colonizer); $thumb_name = "http://img.youtube.com/vi/".$colonizer[1]."/default.jpg"; Quote Link to comment https://forums.phpfreaks.com/topic/164840-php-explode-function-help/#findComment-869198 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.