3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rule = [ "c" => "d", "a" => "o", "t" => "g", "h" => "a", "1" => "@", "e" => "n", "n" => "t" ]; $order = str_split("cat1hen"); $str =""; foreach($order as $key){ $str .= $rule[$key]; } $str = preg_replace("/(.*?)(@)(.)(.*)/", "$1$3$2$4", $str); echo $str; //doga@nt

preferences:
168.98 ms | 405 KiB | 5 Q