1

I have this array and when I search for the uid, I need the array returned where the key was found, so if I search '4048' I should get the second array.

Any help?

$forminfo = array
(
    (0) => array
        (
            (uid) => '100',
            (name) => 'Sandra Shush',
            (url) => 'urlof100'
        ),

    (1) => array
        (
            (uid) => '5465',
            (name) => 'Stefanie Mcmohn',
            (pic_square) => 'urlof100'
        ),

    (2) => array
        (
            (uid) => '40489',
            (name) => 'Michael',
            (pic_square) => 'urlof40489'
        )
);

Thanks in advance

Guilherme Franco
  • 1,465
  • 12
  • 19
Vrutin Rathod
  • 900
  • 1
  • 12
  • 16

1 Answers1

2
function search_inner($forminfo, $uid) {
    for ($i = 0; $i < count($forminfo); $i++) {
        if ($forminfo[$i]['uid'] == $uid) {
            return $forminfo[$i];
        }
    }
}

I don't think there's a built-in way to do this, so this should do the trick.

lucasnadalutti
  • 5,818
  • 1
  • 28
  • 48