开发者

Strtr requires an array as the second argument?

开发者 https://www.devze.com 2023-03-09 13:45 出处:网络
I am calling code like strtr($somevars[\'thisvar\'], \"abc\") Where $somevars[\'thisvar\'] contains a string.

I am calling code like

strtr($somevars['thisvar'], "abc")

Where $somevars['thisvar'] contains a string.

And it's giv开发者_JAVA技巧ing me

Warning:  strtr() [function.strtr]: The second argument is not an array

Why?


Warning: strtr() [function.strtr]: The second argument is not an array

strtr != strstr

see: http://docs.php.net/strtr


You have two possibilties for strtr:

string strtr ( string $str , string $from , string $to );

string strtr ( string $str , array $replace_pairs );

So even you add a third parameters and you can use a string, or you set an array and don't add a third parameter :)

0

精彩评论

暂无评论...
验证码 换一张
取 消