문제

I have an php array of 99 numbers.

The array contains the digits 1 to 100 with one digit missing.

How to know the missing number?

도움이 되었습니까?

해결책

Since you say you've found an answer yourself, here is a possible solution

$assignmentArray = array(1,2,3,4,5,6,7,8,10);

// find the missing fie... err.. missing value is actually more correct.
$missingNumber = array_sum(range(1, 10)) - array_sum($assignmentArray);
echo 'The missing number is: ' . $missingNumber;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top