3v4l.org

run code in 500+ PHP versions simultaneously
<?php $map = [ 'foo' => 'bar', 'foobar' => 'foo', ]; $input = 'foobar and foo'; echo str_replace(array_keys($map), array_values($map), $input); // Output: "bar bar and bar" echo strtr($input, $map); // Output: "baz and bar"
Output for 8.2.32, 8.3.5 - 8.3.33, 8.4.9 - 8.4.24, 8.5.7 - 8.5.9
barbar and barfoo and bar

preferences:
39.93 ms | 525 KiB | 4 Q