PHP preg_replace_callback with unicode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
I am sure both use the same php.ini.

Any idea why it behaves differently?
How do I make it work through web server?


Thanks
-----

<?php
function myCallback($matches) {
    return $matches[0]; //do nothing, test only
}

$value = 'aaa äää';
$pattern = '/(\bäää)/u';

$value = preg_replace_callback($pattern, 'myCallback', $value, -1, $count);
if ($count > 0) {
    echo "match";
} else {
    echo 'no match';
}
?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux