php - How to replace any thing between http:// and first slash / after http://? -
i got url string want replace between http:// , first slash / (in example want replace proxy-63.somesite.com video2.de.secondsite.net). 1 tell me how can done ?thanks
note: data between http:// , first slash after dynamic cant use replace function!
http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8 replaced : http://video2.de.secondsite.net/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8
the original url can different each time, preg_match find root.
$url = 'http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8'; preg_match('@^(?:http://)?([^/]+)@i', $url, $domain); $host = $domain[1]; $newurl = str_replace($host, 'video2.de.secondsite.net', $url); echo $newurl;
Comments
Post a Comment