in reply to getting elements from an array based on a value not in the array
I.e., what do you want to get if $target = 5 or if $target = 0?
After you define this, all you need is to implement binary search like BrowserUK's.
NOTE: his solution does not handle the case when $target is outside the array at all.
|
|---|