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

前端 未结 15 2089
闹比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条回答
  •  旧时难觅i
    2020-11-22 00:42

    http://snipplr.com/view/51108/nested-array-search-by-value-or-key/

     $value) {
            if ($search === ${${"mode"}})
                return true;
        }
        return false;
    }
    
    $data = array(
        array('abc', 'ffffd'),
        'ccc',
        'bbb',
        array('aaa', array('yyy', 'mp' => 555))
    );
    
    var_dump(searchNestedArray($data, 555));
    

提交回复
热议问题