dodgeitorelse3 Posted November 25, 2022 Share Posted November 25, 2022 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? Quote Link to comment https://forums.phpfreaks.com/topic/315582-get-all-keys-that-match-value-from-multidimensional-array/ Share on other sites More sharing options...
Solution Barand Posted November 25, 2022 Solution Share Posted November 25, 2022 Use array keys instead of array_search $results = array_keys(array_column($data, 'oname'), 'Border.aao'); Quote Link to comment https://forums.phpfreaks.com/topic/315582-get-all-keys-that-match-value-from-multidimensional-array/#findComment-1602943 Share on other sites More sharing options...
dodgeitorelse3 Posted November 25, 2022 Author Share Posted November 25, 2022 Thank you Barand Quote Link to comment https://forums.phpfreaks.com/topic/315582-get-all-keys-that-match-value-from-multidimensional-array/#findComment-1602944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.