Coding question

3 years ago

Michael3823

a function that returns the sum of 2 of the biggest numbers in the array.

Code

function sumOfTwo(array $array ){
	
	$firstValue;
	$secondValue;
	
	foreach ($array as $i) {

    	if($i > $value){
    		$secondValue = $firstValue;
    		$firstValue = $i;
    	}
    	else if($i > $secondValue and 
    		$i != $firstValue){
    	$secondValue = $i;
          
    	}
	}

return($firstValue + $secondValue);

  
}

Output

Error: spawn php ENOENT
Video course: PHP Package Development