What I am trying to do is to convert url of a video on youtube/vimeo return a new url that can be embed into an iframe and automate video embed codes.
This is working like a charm.
$url = "http://vimeo.com/29431603";
$orj_value = array("watch?v=", "http://vimeo.com/");
$new_value = array("embed/", "http://player.vimeo.com/video/");
$url = str_replace($orj_value, $new_value, $url);
echo $url;
You know, youtube ads an ugly string too into url that starts with &, so when i include
$url = substr($url, 0, strpos($url, "&"));
before
echo $url;
it strips out the unwanted part of youtube url. But then, vimeo code which has no & inside just does not return anything. Seems after adding new line, code wants to see a & inside the url; otherwise to echo $url var displays blank screen.
2- For dailymotion, i need to strip out everything after first _ How should i edit the line below in order to include support of dailymotion too?
$url = substr($url, 0, strpos($url, "&"));
Thanks in advance to anyone going to answer :)