A WordPress-centric search engine for devs and theme authors



wp_array_slice_assoc ›

Since3.1.0
Deprecatedn/a
wp_array_slice_assoc ( $array, $keys )
Parameters: (2)
  • (array) $array The original array.
    Required: Yes
  • (array) $keys The list of keys.
    Required: Yes
Returns:
  • (array) The array slice.
Defined at:
Codex:

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



Source

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

	return $slice;
}