Вы ищете это?
$url = 'https://www.themoviedb.org/movie/49730-red-riding-hood?language=en-US';
$urlFromBrowser = $_SERVER['HTTP_HOST']; // or you can get the url from the browser
$id = preg_split('#([0-9]+)#', $url, null, PREG_SPLIT_DELIM_CAPTURE)[1];
echo $id;
// ALTERNATIVE REGEX
$id2 = str_replace('-', '', preg_split('#([0-9]+[-]{1})#', $url, null, PREG_SPLIT_DELIM_CAPTURE)[1]); // this REGEX takes in case the '-' after the number so it can be better to check with this one if the URL might contain multiple numbers at different positions
echo $id2;