📜  如何在对象php代码示例中查找值

📅  最后修改于: 2022-03-11 14:53:38.179000             🧑  作者: Mango

代码示例2
function lookup($array, $key) {

    //loop through all values in array
    foreach($array as $values) {

        //if 'key' value matches `$key`, return 'value' value.
        if($values['key'] == $key) {
            return $values['value'];
        }

    }

    //if nothing has been returned, return empty string
    return "";
}