Mega Code Archive

 
Categories / Php / Strings
 

Pass a fourth parameter to preg_replace( ) to specify the maximum number of replacements you want to make

<?     $a = "Foo moo boo tool foo";     $b = preg_replace("/[A-Za-z]oo\b/e", 'strtoupper("$0")', $a, 2);     print $b; ?>