array_replace for PHP


/ Published in: PHP
Save to your folder(s)

Emulate native PHP 5.3 function.


Copy this code and paste it in your HTML
  1. if (!function_exists('array_replace')) {
  2.  
  3. /**
  4.   * Emulate PHP 5.3 function
  5.   *
  6.   * @return type array
  7.   */
  8. function array_replace() {
  9. $arrays = func_get_args();
  10. for($i=1; $i<count($arrays); $i++){
  11. if ( !is_array($arrays[$i]) )
  12. continue;
  13. foreach ($arrays[$i] as $key => $value) {
  14. $arrays[0][$key] = $value;
  15. }
  16. }
  17. return $arrays[0];
  18. }
  19.  
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.