Skip to content

Commit

Permalink
Merge pull request #1 from awheel/v0.1
Browse files Browse the repository at this point in the history
V0.1
  • Loading branch information
fengqi committed Dec 1, 2020
2 parents 97c73f1 + d0512c8 commit 15cf65b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static public function group($array, $field, $callback = null)
}

/**
* Get a subset of the items from the given array.
* 从数组种获取指定 key 的数据,和 Arr::except 相反
*
* @param array $array
* @param array|string $keys
Expand All @@ -121,6 +121,18 @@ static public function only($array, $keys)
return array_intersect_key($array, array_flip((array) $keys));
}

/**
* 从数组种获取指定 key 以外的全部数据,和 Arr::only 相反
*
* @param $array
* @param $keys
*
* @return array
*/
static public function except($array, $keys) {
return array_diff_key($array, array_flip((array) $keys));
}

/**
* 使用二维数组下指定字段作为 key 组成新的数组
*
Expand Down

0 comments on commit 15cf65b

Please sign in to comment.