RecursiveArrayAccess.php 715 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\ResourceBundle\Util;
  11. /**
  12. * @author Bernhard Schussek <bschussek@gmail.com>
  13. */
  14. class RecursiveArrayAccess
  15. {
  16. public static function get($array, array $indices)
  17. {
  18. foreach ($indices as $index) {
  19. if (!$array instanceof \ArrayAccess && !is_array($array)) {
  20. return null;
  21. }
  22. $array = $array[$index];
  23. }
  24. return $array;
  25. }
  26. private function __construct() {}
  27. }