lithium\util\Set::slice()

public static method

Slices an array into two, separating them determined by an array of keys.

Usage examples:


Parameters

  • array $subject

    Array that gets split apart

  • array|string $keys

    An array of keys or a single key as string

Returns

array

An array containing both arrays, having the array with requested keys first and the remainder as second element

Source

	public static function slice(array $data, $keys) {
		$removed = array_intersect_key($data, array_fill_keys((array) $keys, true));
		$data = array_diff_key($data, $removed);
		return array($data, $removed);
	}