[Solved] Smallest integer that is not present in the array


Not sure what you were trying to do in your code, but just start at 1, check and increment. The loop will stop as soon as $i is not found in the array:

function solution($A) {
    for($i=1; in_array($i, $A); $i++);
    return $i;
}

1

solved Smallest integer that is not present in the array