Mega Code Archive

 
Categories / Php / Strings
 

Using preg_match_all() to Match a Pattern Globally

<html> <head> <title>Using preg_match_all() to Match a Pattern Globally</title> </head> <body> <?php $text = "plants, pianos and parrots"; if ( preg_match_all( "/\bp\w+s\b/", $text, $array ) ) {   print "<pre>\n";   print_r( $array );   print "</pre>\n"; } ?> </body> </html>