How to search by key=>value in a multidimensional array in PHP

前端 未结 15 2046
闹比i
闹比i 2020-11-22 00:13

Is there any fast way to get all subarrays where a key value pair was found in a multidimensional array? I can\'t say how deep the array will be.

Simple example arra

15条回答
  •  借酒劲吻你
    2020-11-22 00:57

    Here is solution:

    ");
    $students['ter1003']['birthplace'] = ("San Juan 
    "); $students['fgg1003']['birthplace'] = ("Quezon City
    "); $students['bdf1003']['birthplace'] = ("Manila
    "); $key = array_search('Delata Jona', array_column($students, 'name')); echo $key; ?>

提交回复
热议问题