For example I have this url:
I need to strip out the "tt0274518" from it. Whats the cleanest way of doing so?
keep in mind, it should also work with any of these versions:
Any ideas?
Explode around /title/
is the ID always going to have a fixed length or can it change?
$url = 'http://www.imdb.com/title/tt0274518/'; $url_array = explode("/",$url); $id_index = array_search("title",$url_array) + 1; $movie_id = $url_array[$id_index];
why didnt I think of that? lol
works great, thanks
buy it. read it. dominate.
some guy wrote an imdb api. not sure if it will be helpful.
$url = 'http://www.imdb.com/title/tt0274518/'; $pattern = '/title/(.*?)//i'; preg_match($pattern,$url,$match); $id = $match[1]; print $id; |
don’t forget to account for the /title/tt0274518 type urls…
$pattern = '/title/([^/]+)/i';
buy it. read it. dominate. |
pw?