3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'I loved you'; $from = 'love'; $to = 'lOvE'; var_dump($result1 = strtr($str, $from, $to)); var_dump($result2 = strtr($str, [$from[0] => $to[0], $from[1] => $to[1], $from[2] => $to[2], $from[3] => $to[3]])); var_dump($result2 = strtr($str, [$from => $to])); var_dump($result1===$result2);//false
Output for 7.0.0 - 7.0.23, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.20, 8.1.0 - 8.1.7
string(11) "I lOvEd yOu" string(11) "I lOvEd yOu" string(11) "I lOvEd you" bool(false)

preferences:
38.05 ms | 410 KiB | 5 Q