Getting certain array from a multidimensional array

Posted by Leron on Stack Overflow See other posts from Stack Overflow or by Leron
Published on 2012-04-04T11:22:27Z Indexed on 2012/04/04 11:28 UTC
Read the original article Hit count: 152

Filed under:
|

I have multidimensional array which is a query returning the info from a table named 'users'. In another part of my code I need to get the records of only one certain user and I want to take it using the array I mentioned above. It's of type:

array(24) {
  [0]=>array(9) {
    ["id"]=>string(1) "1"
 ...
   }
  [1]=>array(9) {
    ["id"]=>string(1) "2"
  ...
  }
  [2]=>array(9) {
    ["id"]=>string(1) "5"
...}

I'll use foreach compairing by ["id"] to find the record I need, but when I get a match I'm not sure how to extract only this array from the parent one.

Thanks

Leron

© Stack Overflow or respective owner

Related posts about php

Related posts about codeigniter