_rest_array_intersect_key_recursive() – Recursively computes the intersection of arrays using keys for comparison.

You appear to be a bot. Output may be restricted

Description

Recursively computes the intersection of arrays using keys for comparison.

Usage

$array = _rest_array_intersect_key_recursive( $array1, $array2 );

Parameters

$array1
( array ) required – The array with master keys to check.
$array2
( array ) required – An array to compare keys against.

Returns

array An associative array containing all the entries of array1 which have keys that are present in all arguments.

Source

File name: wordpress/wp-includes/rest-api.php
Lines:

1 to 9 of 9
function _rest_array_intersect_key_recursive( $array1, $array2 ) {
  $array1 = array_intersect_key( $array1, $array2 );
  foreach ( $array1 as $key => $value ) {
    if ( is_array( $value ) && is_array( $array2[ $key ] ) ) {
      $array1[ $key ] = _rest_array_intersect_key_recursive( $value, $array2[ $key ] );
    }
  }
  return $array1;
}
 

 View on GitHub View on Trac