选择语言 :

 Core_Arr::pluck

Retrieves muliple single-key values from a list of arrays.

// Get all of the "id" values from a result
$ids = Arr::pluck($result, 'id');
A list of arrays is an array that contains arrays, eg: array(array $a, array $b, array $c, ...)
array Core_Arr::pluck( array $array , string $key )

参数列表

参数 类型 描述 默认值
$array array List of arrays to check
$key string Key to pluck
返回值
  • array
File: ./core/classes/arr.class.php
public static function pluck($array, $key)
{
	$values = array();

	foreach ($array as $row)
	{
		if (isset($row[$key]))
		{
			// Found a value in this row
			$values[] = $row[$key];
		}
	}

	return $values;
}