英[strɪŋ] 美[strɪŋ]

n.String; rope, belt; thread, plant fiber; [Computer Science] String

vt. Winding, tuning; To line up in a line or a series; to tie, tie or hang with a thread; to extend or extend

Third person singular: strings Plural: strings Present participle: stringing Past tense: strung Past participle: strung

php strtr() function syntax

Function:Convert certain characters in the string

Syntax:strtr(string,from,to)or strtr(string,array)

Parameters:

##Parameters Description string Required. Specifies the string to be converted. from Required (unless using an array). Specifies the character to be changed. to Required (unless using an array). Specifies the character to change to. array Required (unless from and to are used). An array in which the key name is the original character of the change and the key value is the target character of the change.

#Description:Convert specific characters in the string. If the lengths of the from and to parameters are different, they will be formatted to the shortest length.

php strtr() function example

"; //替换数组中的元素 $arr = array("Hello" => "Hi", "world" => "php.cn"); echo strtr("Hello world",$arr); ?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Hello php.cn Hi php.cn


 "Hi", "world" => "php.cn"); echo strtr("Hello world",$arr); ?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Hi php.cn