628 max product of 3 numbers
<?php
function maximumProduct($nums) {
$count=count($nums);
sort($nums);
//for all positive numbers-$prod1:
$prod1=$nums[$count-1]*$nums[$count-2]*$nums[$count-3];
//for negative numbers-$prod2:
$prod2=$nums[0]*$nums[1]*$nums[$count-1];
return max($prod1, $prod2);
}
echo maximumProduct([7,2,1,2,3,4])."\n";
echo maximumProduct([-1,-2,-3,1,2,3,4])."\n";