break $url down into three distinct pieces
<?php
$url = "http://www.java2s.com";
$parts = ereg("^(http://www)\.([[:alnum:]]+)\.([[:alnum:]]+)", $url, $regs);
echo $regs[0];
echo "<br>";
echo $regs[1];
echo "<br>";
echo $regs[2];
echo "<br>";
echo $regs[3];
?>
Related examples in the same category