update : 2015.11.03
php.shukuma.com검색:
|
strtr(PHP 4, PHP 5) strtr — Translate characters or replace substrings 설명
string strtr
( string
$str
, string $from
, string $to
)
string strtr
( string
$str
, array $replace_pairs
)
If given three arguments, this function returns a copy of
If If given two arguments, the second should be an array in the form array('from' => 'to', ...). The return value is a string where all the occurrences of the array keys have been replaced by the corresponding values. The longest keys will be tried first. Once a substring has been replaced, its new value will not be searched again.
In this case, the keys and the values may have any length, provided that
there is no empty key; additionally, the length of the return value may
differ from that of 인수
반환값Returns the translated string.
If 예제
Example #1 strtr() example
<?php The next example shows the behavior of strtr() when called with only two arguments. Note the preference of the replacements ("h" is not picked because there are longer matches) and how replaced text was not searched again. Example #2 strtr() example with two arguments
<?php 위 예제의 출력: hello all, I said hi The two modes of behavior are substantially different. With three arguments, strtr() will replace bytes; with two, it may replace longer substrings. Example #3 strtr() behavior comparison
<?php 위 예제의 출력: 1001 ba01 |