Displaying elements of $regs array : ereg « String « PHP






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

1.Capturing Text Inside HTML or XML Tags
2.Filling Patterns with ereg
3.ereg() function searches a string, returning true if the pattern is found, and false otherwise.
4.ereg.php
5.break $url down into three distinct pieces