Jump to content

get all keys that match value from multidimensional array


Go to solution Solved by Barand,

Recommended Posts

I have an array like this:

Array
(
    [0] => Array
        (
            [id] => 1
            [oname] => Border.aao
            [osize] => 11441673
        )

    [1] => Array
        (
            [id] => 2
            [oname] => Border.aao
            [osize] => 8194731
        )

    [2] => Array
        (
            [id] => 3
            [oname] => Border.aao
            [osize] => 8104714
        )

    [3] => Array
        (
            [id] => 4
            [oname] => BRM_Range.aao
            [osize] => 6848551
        )

    [4] => Array
        (
            [id] => 5
            [oname] => camp_mackall.aao
            [osize] => 17524696
        )

    [5] => Array
        (
            [id] => 6
            [oname] => Canyon.aao
            [osize] => 13310448
        )

    [6] => Array
        (
            [id] => 7
            [oname] => District.aao
            [osize] => 21848613
        )
)

I tried to get all keys that match a search value such as Border.aao

$mykey = array_search("Border.aao", array_column($duplicate_mapname_array_snames, 'oname'));

but this only gives me the first key. I want to get all the keys which should be 0,1 and 2

 

How do I achieve this?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.