Mega Code Archive

 
Categories / Php / Strings
 

$0 is set to the whole match, then $1, $2

<?     $match = "/the (car|cat) sat on the (drive|mat)/";     $input = "the cat sat on the mat";     print preg_replace($match, "Matched $0, $1, and $2\n", $input); ?>