wp_array_slice_assoc( array $array, array $keys )

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

Description Description

Parameters Parameters


(array) (Required) The original array.


(array) (Required) The list of keys.

Top ↑

Return Return

(array) The array slice.

Top ↑

Source 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 Changelog

Version Description
3.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.