wp_array_slice_assoc( array $array, array $keys )

Extract a slice of an array, given a list of keys.


Description


Parameters

$array

(array) (Required) The original array.

$keys

(array) (Required) The list of keys.


Top ↑

Return

(array) The array slice.


Top ↑

Source

File: wp-includes/functions.php

function wp_array_slice_assoc( $array, $keys ) {
	$slice = array();
	foreach ( $keys as $key ) {
		if ( isset( $array[ $key ] ) ) {
			$slice[ $key ] = $array[ $key ];
		}
	}

	return $slice;
}

Top ↑

Changelog

Version Description
3.1.0 Introduced.