WordPress at a glance

wp_array_slice_assoc() WP 1.0

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

Возвращает

Array. The array slice.

Использование

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

Changelog

Since 3.1.0 Introduced.

Код wp_array_slice_assoc() WP 5.5.1

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

	return $slice;
}

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

More from category: Helper Functions

No comments
    Log In . Register