Well, slightly bad choice of error message wording on my part - 0 is actually 'no error', so it's apparently not a pattern error. [S]But what I don't understand is why you seem to be getting NULL returned if there's no error.[/S] (See below)
I tried your code in a test script and it works for me:
PHP Code:
<?php
$pat = array(
'/\bfoo\b/i'
);
$rep = array(
' boo'
);
$text = " foo ";
$ret = preg_replace($pat, $rep, $text);
if ($ret !== NULL)
echo "new text :" . $ret;
else
echo ("preg_replace error: " . preg_last_error());
and the output is:
ETA: OK, further testing, that error code returned from preg_last_error isn't very useful - I purposely put in a bad pattern and I got NULL as a return, but 0 from preg_last_error(), just like you did. So I guess you *do* have an error in one of your patterns. I assume what you posted is a simplified version of what you're actually using, so I guess you'll have to look them over carefully to check for bad pattern string syntax.