Given the following array and a given id, how can I return the corresponding elem? For instance, given id=6, it should return goodby. The id values are the PKs from a database, thus will always be unique.
Obviously, I could just iterate over the first array, check the values, and break and return the elem upon match, but I expect there is a much more elegant way to do this.
array(
array('id'=>2,'elem'=>"hello"),
array('id'=>6,'elem'=>"goodby"),
array('id'=>8,'elem'=>"goodnight")
);