Arr.php 802 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Luracast\Restler\Data;
  3. /**
  4. * Convenience class for Array manipulation
  5. *
  6. * @category Framework
  7. * @package Restler
  8. * @author R.Arul Kumaran <arul@luracast.com>
  9. * @copyright 2010 Luracast
  10. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  11. * @link http://luracast.com/products/restler/
  12. *
  13. */
  14. class Arr
  15. {
  16. /**
  17. * Deep copy given array
  18. *
  19. * @param array $arr
  20. *
  21. * @return array
  22. */
  23. public static function copy(array $arr)
  24. {
  25. $copy = array();
  26. foreach ($arr as $key => $value) {
  27. if (is_array($value)) $copy[$key] = static::copy($value);
  28. else if (is_object($value)) $copy[$key] = clone $value;
  29. else $copy[$key] = $value;
  30. }
  31. return $copy;
  32. }
  33. }