Displaying elements of $regs array
<?
$url = "http://www.java2s.com";
$www_url = ereg("^(http://www)\.([[:alnum:]]+)\.([[:alnum:]]+)", $url, $regs);
if ($www_url) :
echo $regs[0];
print "<br>";
echo $regs[1];
print "<br>";
echo $regs[2];
print "<br>";
echo $regs[3];
endif;
?>
Related examples in the same category