I wrote a simple script below to simulate my problem. Both my string and pattern contain unicode characters.
Basically, if I run it from command line (php -f test.php), it prints "match" as expected. But if I run it through web server (apache, http://localhost/test.php), it prints "no match". I am using PHP 5.3.
Any idea why it behaves differently? How do I make it work through web server?
thanks.
<?php
function myCallback($matches) {
return $matches[0];
}
$value = 'aaa äää';
$pattern = '/(\bäää)/u';
$value = preg_replace_callback($pattern, 'myCallback', $value, -1, $count);
if ($count > 0) {
echo "match";
} else {
echo 'no match';
}
?>