[UPHPU] better way to find position in an array of numeric values?

Justin Hileman justin at justinhileman.info
Sat May 2 09:40:35 MDT 2009


Wade Preston Shearer wrote:
> I have an array called $things that I am iterating through. On each loop
> I need to echo out some values of the sub-array. I also need to echo out
> a "position." The position is a text string representation of a numeric
> value. I have an array of possible positions. The correct position is
> the one immediately less than the ID. So, if the ID was 32, then the
> position would be 'b'. Is there a more efficient way to determine and
> return the position than how I am doing it below?


Are you looking for "efficient == less lines of code", "efficient == 
code makes sense later" or "efficient == faster" ?

-- 
justin
http://justinhileman.com



More information about the UPHPU mailing list