V Posted June 29, 2010 Share Posted June 29, 2010 I'm not sure how to do this.. I'm using a Jquery script that expands YouTube videos when you click on a link or thumbnail but it works only with this type of YouTube url - for a full screen video. but generally a youtube link is like this. I need to remove "watch", "?", and replace "=" with "/" I submit these links via a form input. Instead of manually changing the URL it would be neat if I can just paste it and let php do the rest. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 29, 2010 Share Posted June 29, 2010 You are making it harder than it needs to be by trying to replace characters before and after the "v". Just do a simple replace of '/watch?v=' with '/v/' using str_replace(). $link = str_replace('/watch?v=', '/v/', $link); Quote Link to comment Share on other sites More sharing options...
plutomed Posted June 29, 2010 Share Posted June 29, 2010 $link = preg_replace("/watch\?v=/", "v/", $var); Edit: Or what mjdamato said. Quote Link to comment Share on other sites More sharing options...
V Posted June 29, 2010 Author Share Posted June 29, 2010 Thank you for the code! It's work perfectly Quote Link to comment 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.