@@ 561-578 (lines=18) @@ | ||
558 | * |
|
559 | * @return |
|
560 | */ |
|
561 | final protected function multidimensional_replace( $root, $keys, $value ) { |
|
562 | ||
563 | if ( ! isset( $value ) ) { |
|
564 | return $root; |
|
565 | } elseif ( empty( $keys ) ) { |
|
566 | // If there are no keys, we're replacing the root. |
|
567 | return $value; |
|
568 | } |
|
569 | ||
570 | $result = $this->multidimensional( $root, $keys, true ); |
|
571 | ||
572 | if ( isset( $result ) ) { |
|
573 | $result['node'][ $result['key'] ] = $value; |
|
574 | } |
|
575 | ||
576 | return $root; |
|
577 | ||
578 | } |
|
579 | ||
580 | /** |
|
581 | * Will attempt to fetch a specific value from a multidimensional array. |
|
@@ 589-606 (lines=18) @@ | ||
586 | * |
|
587 | * @return mixed The requested value or the default value. |
|
588 | */ |
|
589 | final protected function multidimensional_get( $root, $keys, $default = null ) { |
|
590 | ||
591 | // If there are no keys, test the root. |
|
592 | if ( empty( $keys ) ) { |
|
593 | if ( isset( $root ) ) { |
|
594 | return $root; |
|
595 | } |
|
596 | } else { |
|
597 | $result = $this->multidimensional( $root, $keys ); |
|
598 | ||
599 | if ( isset( $result ) ) { |
|
600 | return $result['node'][ $result['key'] ]; |
|
601 | } |
|
602 | } |
|
603 | ||
604 | return $default; |
|
605 | ||
606 | } |
|
607 | ||
608 | /** |
|
609 | * Will attempt to check if a specific value in a multidimensional array is set. |