Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php array search on equal or less than suggestions?

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
Currently I'm using a "for" loop to examine each element of an array comparing for "equal or less than" of the element to the argument value. This seams like a cumbersome way to accomplish this task so I've been searching for alternative ways to do this without success.

Therefore, given a single dimension array with values that are in ascending sequence, can anyone suggest a better method to locate the element index number that is eiher equal to or less than but closest to the value in the argument?

I'll be very interested to see what everyone can offer!

Thanks all.
 
Question:

Are the values in the array unique or is there the possibility of redundancy?
 
In this case they are absolutely, positively unique. In the case that I am working on now there are only four (4) elements and they are defined statically.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top