3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hex = "abba test baab"; $hex = array_map(function ($x) { return ($x === 'a') ? 'b' : (($x === 'b') ? 'a' : $x); }, str_split($hex)); echo implode('', $hex);

preferences:
28.69 ms | 406 KiB | 5 Q