$array = [2,5,7,9,11];
$target = 11;
function twoSums($array, $target) {
$count = count($array);
for ($i=0;$i<$count;$i++) {
$diff = $target - $array[$i];
$newArray = $array;
unset($newArray[$i]);
if (in_array($diff, $newArray)) {
return [$i, array_search($diff, $newArray)];
}
}
}
$a=twoSums($array, $target);
var_dump($a);