Skip to content

Commit

Permalink
feat: Legacy array implementation
Browse files Browse the repository at this point in the history
Added legacy implementation for array_diff_assoc
  • Loading branch information
seebeen committed Jun 6, 2024
1 parent 4fe3c65 commit 92731d8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xwp-helper-fns.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ function wp_array_flatmap_assoc( callable $callback, array $input, string $key,
endif;

if ( ! function_exists( 'wp_array_diff_assoc' ) ) :
/**
* Legacy function to extract a slice of an array not including the specified keys.
*
* @param array $input_array Input array.
* @param array $keys Keys to exclude.
*/
function wp_array_diff_assoc( array $input_array, array $keys ) {
return xwp_array_diff_assoc( $input_array, ...$keys );
}
endif;

if ( ! function_exists( 'xwp_array_diff_assoc' ) ) :
/**
* Extracts a slice of array not including the specified keys.
*
Expand All @@ -75,7 +87,7 @@ function wp_array_flatmap_assoc( callable $callback, array $input, string $key,
* @param array<string>|string ...$keys Keys to exclude.
* @return array<string, T> Array with the keys removed.
*/
function wp_array_diff_assoc( array $input_array, string|array ...$keys ) {
function xwp_array_diff_assoc( array $input_array, string ...$keys ) {
if ( is_array( $keys[0] ) ) {
$keys = $keys[0];
}
Expand Down

0 comments on commit 92731d8

Please sign in to comment.