If it works with strings, but not with arrays, it simply applies it to strings :-)
$search = array('š','á','ž','í','ě','é','ř','ň','ý','č',' '); $replace = array('s','a','z','i','e','e','r','n','y','c','-'); len = count($safe_files) for ($i=0; $i<len; $i++) $safe_files[$i] = str_replace($search, $replace, $safe_files[$i]);
I think str_replace accept arrays only for the first 2 parameters, and not for the last. Maybe I'm wrong, but it should work anyway.
If in any case you have a real encoding problem, it just might be that your OS uses a single byte encoding, while your source file uses another, possibly UTF-8.
In this case, do something like:
$search = array('š','á','ž','í','ě','é','ř','ň','ý','č',' '); $replace = array('s','a','z','i','e','e','r','n','y','c','-'); $code_encoding = "UTF-8"; // this is my guess, but put whatever is yours $os_encoding = "CP-1250"; // this is my guess, but put whatever is yours len = count($safe_files) for ($i=0; $i<len; $i++) { $safe_files[$i] = iconv($os_encoding , $code_encoding, $safe_files[$i]); // convert before replace /* ALternatively : $safe_files[$i] = mb_convert_encoding($safe_files[$i], $code_encoding , $os_encoding ); */ $safe_files[$i] = str_replace($search, $replace, $safe_files[$i]); }
mb_convert_encoding () requires an ext / mbstring extension, and iconv () requires ext / iconv.