Cobra_Fast
Cobra_Fast

Reputation: 16061

Strtr requires an array as the second argument?

I am calling code like

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

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

And it's giving me

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

Why?

Upvotes: 0

Views: 2489

Answers (2)

Cyril N.
Cyril N.

Reputation: 39859

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 :)

Upvotes: 1

VolkerK
VolkerK

Reputation: 96159

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

strtr != strstr

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

Upvotes: 9

Related Questions