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

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


Parameters

$input_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. View all references

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

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

	return $slice;
}


Top ↑

Changelog

Changelog
Version Description
3.1.0 Introduced.

Top ↑

User Contributed Notes

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