I got the follwing array and I would like to retrieve the name by the id:
Array
(
[0] => Array
(
[id] => 1
[name] => john
)
[1] => Array
(
[id] => 2
[name] => mark
)
etc...
It is doable with double foreach loop and a conditional test, but is there a more elegant way?
foreachis probably the quickest way of doing this as most other ways involve at least 1 pass of the entire array to convert it to a id => name array (unless you can generate this in the first place).