选择语言 :

 Core_Arr::extract

Retrieves multiple keys from an array. If the key does not exist in the array, the default value will be added instead.

// Get the values "username", "password" from $_POST
$auth = Arr::extract($_POST, array('username', 'password'));
array Core_Arr::extract( array $array , array $keys [, mixed $default = null ] )

参数列表

参数 类型 描述 默认值
$array array Array to extract keys from
$keys array List of key names
$default mixed Default value null
返回值
  • array
File: ./core/classes/arr.class.php
341
342
343
344
345
346
347
348
349
350
public static function extract($array, array $keys, $default = null)
{
    $found = array();
    foreach ($keys as $key)
    {
        $found[$key] = isset($array[$key]) ? $array[$key] : $default;
    }
 
    return $found;
}