wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_rest_array_intersect_key_recursive › WordPress Function

Seit5.3.0
Veraltetn/v
_rest_array_intersect_key_recursive ( $array1, $array2 )
Parameter: (2)
  • (array) $array1 The array with master keys to check.
    Erforderlich: Ja
  • (array) $array2 An array to compare keys against.
    Erforderlich: Ja
Gibt zurück:
  • (array) An associative array containing all the entries of array1 which have keys that are present in all arguments.
Definiert in:
Codex:

Recursively computes the intersection of arrays using keys for comparison.



Quellcode

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