Gistrec

arrayCopy [PHP]

Apr 23rd, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. function arrayCopy(array $array) {
  2.     $result = array();
  3.     foreach($array as $key => $val) {
  4.         if(is_array($val)) {
  5.             $result[$key] = self::arrayCopy($val);
  6.         } elseif (is_object($val)) {
  7.             $result[$key] = clone $val;
  8.         } else {
  9.             $result[$key] = $val;
  10.         }
  11.     }
  12.     return $result;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment