WordPress开发者和主题制作者的搜索引擎



wp_array_slice_assoc ›

Since3.1.0
已弃用n/a
wp_array_slice_assoc ( $array, $keys )
参数: (2)
  • (array) $array The original array.
    Required: Yes
  • (array) $keys The list of keys.
    Required: Yes
返回:
  • (array) The array slice.
定义在:
文档:

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



源码

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

	return $slice;
}