<?php $arr = [1,3,45,2,7,0,1,0]; echo removeZeroAndSumFirstThree(); function removeZeroAndSumFirstThree($arr) { asort($arr); //Remove 0 from array $a = array_diff($arr, [0]); $output = array_slice($a, 0, 3); return array_sum($output); }
You have javascript disabled. You will not be able to edit any code.