@@ 634-651 (lines=18) @@ | ||
631 | * |
|
632 | * @return |
|
633 | */ |
|
634 | final protected function multidimensional_replace( $root, $keys, $value ) { |
|
635 | ||
636 | if ( ! isset( $value ) ) { |
|
637 | return $root; |
|
638 | } elseif ( empty( $keys ) ) { |
|
639 | // If there are no keys, we're replacing the root. |
|
640 | return $value; |
|
641 | } |
|
642 | ||
643 | $result = $this->multidimensional( $root, $keys, true ); |
|
644 | ||
645 | if ( isset( $result ) ) { |
|
646 | $result['node'][ $result['key'] ] = $value; |
|
647 | } |
|
648 | ||
649 | return $root; |
|
650 | ||
651 | } |
|
652 | ||
653 | /** |
|
654 | * Will attempt to fetch a specific value from a multidimensional array. |
|
@@ 662-679 (lines=18) @@ | ||
659 | * |
|
660 | * @return mixed The requested value or the default value. |
|
661 | */ |
|
662 | final protected function multidimensional_get( $root, $keys, $default = null ) { |
|
663 | ||
664 | // If there are no keys, test the root. |
|
665 | if ( empty( $keys ) ) { |
|
666 | if ( isset( $root ) ) { |
|
667 | return $root; |
|
668 | } |
|
669 | } else { |
|
670 | $result = $this->multidimensional( $root, $keys ); |
|
671 | ||
672 | if ( isset( $result ) ) { |
|
673 | return $result['node'][ $result['key'] ]; |
|
674 | } |
|
675 | } |
|
676 | ||
677 | return $default; |
|
678 | ||
679 | } |
|
680 | ||
681 | /** |
|
682 | * Will attempt to check if a specific value in a multidimensional array is set. |