3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cryptArray = array( "a"=>"xyz","b"=>"256"); $string = "aab"; function cryptit($string,$cryptArray){ $temp = ""; $length = strlen($string); for($i=0; $i<$length; $i++){ $temp .= $cryptArray[$string[$i]]; } return $temp; } function decryptit($string,$cryptArray){ $temp = ""; $length = strlen($string); $cryptArray = array_flip($cryptArray); for($i =0; $i<$length; $i = $i+3){ $temp .= $cryptArray[$string[$i].$string[$i+1].$string[$i+2]]; } return $temp; } $crypted = cryptit($string,$cryptArray); echo $crypted; $decrypted = decryptit($crypted,$cryptArray); echo $decrypted;
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
xyzxyz256aab

preferences:
110.33 ms | 407 KiB | 5 Q