$value){ $answer += $value; if($answer >= $all){ $answer_i[] = $key; } } if($answer_i[0] === 0){ echo 1; }else{ echo $answer_i[0]; } echo "\n";