WordPress at a glance

wp_array_slice_assoc() WP 1.0

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

✈ 1 time = 0.000017s = very fast | 50000 times = 0.08s = speed of light PHP 7.0.4, WP 4.4.2

No Hooks.

Return

Array. The array slice.

Usage

wp_array_slice_assoc( $array, $keys );
$array(array) (required)
The original array.
$keys(array) (required)
The list of keys.

Code of wp_array_slice_assoc: wp-includes/functions.php VER 4.9.8

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

	return $slice;
}

Related Functions

From tag: array list help functions (sorting arrays objects)

More from category: Helper Functions

No comments
    Hello, !     Log In . Register