PHP strtr() İşlev
Örnek
Dizedeki "ia" karakterlerini "eo" ile değiştirin:
<?php
echo strtr("Hilla Warld","ia","eo");
?>
Tanım ve Kullanım
strtr() işlevi, bir dizedeki belirli karakterleri çevirir.
Not: from ve to parametrelerinin uzunluğu farklıysa, her ikisi de en kısa olanın uzunluğuna göre biçimlendirilir.
Sözdizimi
strtr(string,from,to)
veya
strtr(string,array)
Parametre Değerleri
Parameter | Description |
---|---|
string | Required. Specifies the string to translate |
from | Required (unless array is used). Specifies what characters to change |
to | Required (unless array is used). Specifies what characters to change into |
array | Required (unless to and from is used). An array containing what to change from as key, and what to change to as value |
Teknik detaylar
Geri dönüş değeri: | Çevrilmiş dizeyi döndürür. Dizi parametresi boş bir dize ("") olan bir anahtar içeriyorsa , YANLIŞ döndürür. |
---|---|
PHP Sürümü: | 4+ |
Daha fazla örnek
Örnek
"Merhaba dünya" dizesini "Merhaba dünya" ile değiştirin:
<?php
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr);
?>
❮ PHP Dize Referansı