3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($input){ $len = count($input); for($a = 0; $a < $len; $a++){ for($b = 0; $b < $len; $b++){ if($input[$a] === strrev($input[$b]) || $input[$b] === strrev($input[$a]) && $input[$a] === $input[$b]){ $str = $input[$b]; $pos = ceil(strlen($str) / 2) - 1; return $b." ".substr($str, $pos, 1); } } } } $input = array("abc", "def", "feg", "cba"); echo test($input)."\n"; ?>

preferences:
44.85 ms | 402 KiB | 5 Q