wc_array_overlay

Merge two arrays.

Description

(array) wc_array_overlay( (array) $a1, (array) $a2 ); 

Returns (array)

Parameters (2)

0. $a1 (array)
The a1.
1. $a2 (array)
The a2.

Usage

  1. if ( !function_exists( 'wc_array_overlay' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The a1. 
  5. $a1 = array(); 
  6.  
  7. // The a2. 
  8. $a2 = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_array_overlay($a1, $a2); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_array_overlay( $a1, $a2 ) { 
  2. foreach ( $a1 as $k => $v ) { 
  3. if ( ! array_key_exists( $k, $a2 ) ) { 
  4. continue; 
  5. if ( is_array( $v ) && is_array( $a2[ $k ] ) ) { 
  6. $a1[ $k ] = wc_array_overlay( $v, $a2[ $k ] ); 
  7. } else { 
  8. $a1[ $k ] = $a2[ $k ]; 
  9. return $a1;