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"

preferences:
52.15 ms | 483 KiB | 5 Q