Something odd going on with str_replace. When I replace a set of double characters with another set (double characters), I get a text length increase of 1.
$gw = array("ll","ch");
$gw2 = array("lž","cž");
$cw = array("â","`");
$cw2 = array("â","à");
$s = str_replace($cw,$cw2,$s);
$s = preg_replace('~[^\\pL\d]+~u', '-', $s);
$s = trim($s);
if (function_exists('iconv')){
$s = iconv('utf-8', 'us-ascii//TRANSLIT', $s);
}
$s = preg_replace('~[^-\w]+~', '', $s);
//text increases by 1 for every occurrance of below:
$out = str_replace($gw,$gw2,$s);
//text displays correct number of characters, but when a replacement is made, a check with strlen() gives an increase of 1.
This is driving me bonkers!
echo strlen($s);//for llanelli: output = 8
$out = str_replace($gw,$gw2,$s);//replace 2 x ll with 2 x lž
echo strlen($out);//for lžanelži: output = 10
Don't ask why I'm doing this - long story! Am I missing something really basic? [Page encoding = utf-8]