I need to find the left-near key of a base array corresponding to a variable value.
Searched value (in this case) is always between 1 and 779
Better with an example:
$fixedArr = [ 0, 5, 8, 20, 40, 60, 90, 135, 780 ];
$search = 42; // $result = $arr[4] -> 4;
$search = 110; // $result = $arr[6] -> 6;
$search = 134; // $result = $arr[6] -> 6;
$search = 135; // $result = $arr[7] -> 7;
I try with a foreach loop but with no luck, any idea?? Thanks