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

📅  最后修改于: 2022-03-11 14:54:02.337000             🧑  作者: 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 "";
}