--TEST-- Test strtr() function : usage variations - string containing special chars for 'str' argument --FILE-- "%", "%" => "$", "#*&@()" => "()@&*#"); /* loop through to test strtr() with each element of $str_arr */ for($index = 0; $index < count($str_arr); $index++) { echo "-- Iteration $count --\n"; $str = $str_arr[$index]; //getting the array element in 'str' variable //strtr() call in three args syntax form var_dump( strtr($str, $from, $to) ); //strtr() call in two args syntax form var_dump( strtr($str, $replace_pairs) ); $count++; } echo "*** Done ***"; ?> --EXPECT-- *** Testing strtr() : string containing special chars for 'str' arg *** -- Iteration 1 -- unicode(1) "s" unicode(1) "$" -- Iteration 2 -- unicode(3) "pec" unicode(3) "#%*" -- Iteration 3 -- unicode(10) "text i als" unicode(10) "text & @()" -- Iteration 4 -- unicode(1) "s" unicode(1) "$" -- Iteration 5 -- unicode(3) "pec" unicode(3) "#%*" -- Iteration 6 -- unicode(10) "text i als" unicode(10) "text & @()" -- Iteration 7 -- unicode(17) "s peci text i als" unicode(17) "$ #%*& text & @()" *** Done ***