wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_array_slice_assoc › WordPress Function

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

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



Source

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;
}