aioseop_array_insert_after

Utility function for inserting elements into associative arrays by key.

Description

(array) aioseop_array_insert_after( $arr, $insertKey, $newValues ); 

Returns (array)

Parameters (3)

0. $arr
The arr.
1. $insertkey
The insertkey.
2. $newvalues
The newvalues.

Usage

  1. if ( !function_exists( 'aioseop_array_insert_after' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'all-in-one-seo-pack/inc/aioseop_functions.php'; 
  3.  
  4. // The arr. 
  5. $arr = null; 
  6.  
  7. // The insertkey. 
  8. $insertkey = null; 
  9.  
  10. // The newvalues. 
  11. $newvalues = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = aioseop_array_insert_after($arr, $insertkey, $newvalues); 
  15.  

Defined (1)

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

/inc/aioseop_functions.php  
  1. function aioseop_array_insert_after( $arr, $insertKey, $newValues ) { 
  2. $keys = array_keys( $arr ); 
  3. $vals = array_values( $arr ); 
  4. $insertAfter = array_search( $insertKey, $keys ) + 1; 
  5. $keys2 = array_splice( $keys, $insertAfter ); 
  6. $vals2 = array_splice( $vals, $insertAfter ); 
  7. foreach ( $newValues as $k => $v ) { 
  8. $keys[] = $k; 
  9. $vals[] = $v; 
  10.  
  11. return array_merge( array_combine( $keys, $vals ), array_combine( $keys2, $vals2 ) );