break $url down into three distinct pieces : ereg « String « PHP






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

1.Capturing Text Inside HTML or XML Tags
2.Displaying elements of $regs array
3.Filling Patterns with ereg
4.ereg() function searches a string, returning true if the pattern is found, and false otherwise.
5.ereg.php