- substr: documentation ( source)
- ceil: documentation ( source)
- strrev: documentation ( source)
<?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";
?>