util.lib.php 750 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Util file creation
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. namespace PMA\Util;
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /**
  13. * Access to a multidimensional array by dot notation
  14. *
  15. * @param array $array List of values
  16. * @param string|array $path Path to searched value
  17. * @param mixed $default Default value
  18. *
  19. * @return mixed Searched value
  20. */
  21. function get($array, $path, $default = null)
  22. {
  23. if (is_string($path)) {
  24. $path = explode('.', $path);
  25. }
  26. $p = array_shift($path);
  27. while (isset($p)) {
  28. if (!isset($array[$p])) {
  29. return $default;
  30. }
  31. $array = $array[$p];
  32. $p = array_shift($path);
  33. }
  34. return $array;
  35. }