3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'i need healing'; function matrix($input) { $inputIdx = str_split($input); $inputLen = strlen($input); for ($i = 0; $i < $inputLen; $i++) { for ($j = 0; $j < $inputLen; $j++) { $key = $i + $j; if (!array_key_exists($i+$j, $inputIdx)) { $key -= $inputLen; } echo $inputIdx[$key]; } echo PHP_EOL; } } matrix($str);

preferences:
54.21 ms | 402 KiB | 5 Q