Must I loop to search results for a specific value?

Posted by tag on Stack Overflow See other posts from Stack Overflow or by tag
Published on 2010-05-05T19:54:29Z Indexed on 2010/05/05 19:58 UTC
Read the original article Hit count: 278

Filed under:
|

I have a table in the database:

name         Opinion
Tim          Tim has an opinion
John         other random text
Dan          Dan's random text
Al           Al says something else

I call this data and get it back in

getRecords.lastResult

To access John's opinion, I could use:

getRecords.lastResult[1].opinion

But that's only because I know that John is the second record (record 1), but this may change. So the right way is to search through the results to first find the record index for John, then access his opinion.

My guess is I need some sort of a loop? Is there an easier way to search for John directly without a loop?

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flex