There is a line: "/ catalog / mebel / divany /"
There is an array: $ trans ["mebel" => "Furniture", "divany" => "Sofas"]
It is necessary to turn from a string of translit into Cyrillic to get "/ catalog / Furniture / Sofas /"
I understand that you need to use str_replace, but it does not work out how to do this in the case of such an array. Or is there another way?
Thank.
|
1 answer
$str = "/catalog/mebel/divany/"; $trans = ["mebel" => "Мебель", "divany" => "Диваны"]; echo str_replace(array_keys($trans), array_values($trans), $str); array_keys - http://php.net/manual/ru/function.array-keys.php
array_values - http://php.net/manual/ru/function.array-values.php
str_replace with arrays example - http://php.net/manual/ru/function.str-replace.php#refsect1-function.str-replace-examples
- Thank you very much. Exactly what is needed! - Leah Hael
|
"/catalog/".$trans["mebel"]."/".$trans["divany"]."/"not suitable? -