Remove array elements that are less than X
- by GGio
I have arrays:
$arr1 = array(5, 3, 9, 11, 6, 15);
$arr2 = array(11, 20, 1, 3, 8);
Now I need to loop through $arr1 and find the largest number that is less than X:
foreach($arr1 as $x) {
//need element that is MAX in $arr2 but is less than $x
}
so for example for the first run when $x = 5, maximum in $arr2 is 3 that is less than 5.
Is it…