PHP Define Pattern And Use Parentheses To Match Individual Elements Within It – String Function

<?
$test = "Whatever you do, don't panic!";
if ( preg_match( "/(don't)\s+(panic)/", $test, $array ) ) {
  print "<pre>\n";
  print_r( $array );
  print "

\n”;
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.