<?php

$url = "http://www.jeuxvideo.com:80/test/forums.htm";
function cut_url($url)
{
    preg_match('`^(a-z0-9+://)?(^/:+)(:\d+)?(/.*$)?`i', $url, $out);
    return $out;
}
print_r(cut_url($url));
/* affichera
Array
(
   0 => http://www.jeuxvideo.com:80/test/forums.htm
   1 => http://
   2 => www.jeuxvideo.com
   3 => :80
   4 => /test/forums.htm
)
*/
?>


Source : expreg.com