function get_first_character_repeated($s) {
$len = strlen($s);
for ($i = 0; $i < $len; $i++) {
for ($j = $i + 1; $j < $len; $j++) {
if ($s[$i] == $s[$j]) {
return $i;
}
}
}
return -1;
}
$s = "abcdxypcbop";
$i = get_first_character_repeated($s);
if ($i == -1) {
echo "Not found";
}
else {
echo $s[$i];
}
/*
run:
b
*/