wordpress / latest / functions / wp_array_slice_assoc.html

wp_array_slice_assoc( array $array, array $keys ): array

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

Parameters

$array array Required
The original array.
$keys array Required
The list of keys.

Return

array The array slice.

Source

File: wp-includes/functions.php. View all references

function wp_array_slice_assoc( $array, $keys ) {
	$slice = array();

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

	return $slice;
}

Used By

Used By Description

Changelog

Version Description
3.1.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_array_slice_assoc