_arrayMergeRecursive example

$thisSection  = $data[$section];

        if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) {
            $this->_assertValidExtend($section$thisSection[self::EXTENDS_NAME]);

            if (!$this->_skipExtends) {
                $config = $this->_processExtends($data$thisSection[self::EXTENDS_NAME]$config);
            }
            unset($thisSection[self::EXTENDS_NAME]);
        }

        $config = $this->_arrayMergeRecursive($config$thisSection);

        return $config;
    }

    /** * Very dumb YAML parser * * Until we have Zend_Yaml... * * @param string $yaml YAML source * @return array Decoded data */
$this->_skipExtends = (bool) $options['skipExtends'];
            }
        }

        $iniArray = $this->_loadIniFile($filename);

        if ($section === null) {
            // Load entire file             $dataArray = [];
            foreach ($iniArray as $sectionName => $sectionData) {
                if (!\is_array($sectionData)) {
                    $dataArray = $this->_arrayMergeRecursive($dataArray$this->_processKey([]$sectionName$sectionData));
                } else {
                    $dataArray[$sectionName] = $this->_processSection($iniArray$sectionName);
                }
            }
            parent::__construct($dataArray$allowModifications);
        } else {
            // Load one or more sections             if (!\is_array($section)) {
                $section = [$section];
            }
            $dataArray = [];
            

    protected function _arrayMergeRecursive($firstArray$secondArray)
    {
        if (is_array($firstArray) && is_array($secondArray)) {
            foreach ($secondArray as $key => $value) {
                if (isset($firstArray[$key])) {
                    $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key]$value);
                } else {
                    if($key === 0) {
                        $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray$value));
                    } else {
                        $firstArray[$key] = $value;
                    }
                }
            }
        } else {
            $firstArray = $secondArray;
        }

        
$nsAttributes = $thisSection->attributes(self::XML_NAMESPACE);

        if (isset($thisSection['extends']) || isset($nsAttributes['extends'])) {
            $extendedSection = (string) (isset($nsAttributes['extends']) ? $nsAttributes['extends'] : $thisSection['extends']);
            $this->_assertValidExtend($section$extendedSection);

            if (!$this->_skipExtends) {
                $config = $this->_processExtends($element$extendedSection$config);
            }
        }

        $config = $this->_arrayMergeRecursive($config$this->_toArray($thisSection));

        return $config;
    }

    /** * Returns a string or an associative and possibly multidimensional array from * a SimpleXMLElement. * * @param SimpleXMLElement $xmlObject Convert a SimpleXMLElement into an array * @return array|string */
    

    protected function _arrayMergeRecursive($firstArray$secondArray)
    {
        if (\is_array($firstArray) && \is_array($secondArray)) {
            foreach ($secondArray as $key => $value) {
                if (isset($firstArray[$key])) {
                    $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key]$value);
                } else {
                    if ($key === 0) {
                        $firstArray = [0 => $this->_arrayMergeRecursive($firstArray$value)];
                    } else {
                        $firstArray[$key] = $value;
                    }
                }
            }
        } else {
            $firstArray = $secondArray;
        }

        
$this->_skipExtends = (bool) $options['skipExtends'];
            }
        }

        $iniArray = $this->_loadIniFile($filename);

        if (null === $section) {
            // Load entire file             $dataArray = array();
            foreach ($iniArray as $sectionName => $sectionData) {
                if(!is_array($sectionData)) {
                    $dataArray = $this->_arrayMergeRecursive($dataArray$this->_processKey(array()$sectionName$sectionData));
                } else {
                    $dataArray[$sectionName] = $this->_processSection($iniArray$sectionName);
                }
            }
            parent::__construct($dataArray$allowModifications);
        } else {
            // Load one or more sections             if (!is_array($section)) {
                $section = array($section);
            }
            $dataArray = array();
            
if (is_array($thisSection[self::EXTENDS_NAME])) {
                throw new Zend_Config_Exception('Invalid extends clause: must be a string; array received');
            }
            $this->_assertValidExtend($section$thisSection[self::EXTENDS_NAME]);

            if (!$this->_skipExtends) {
                $config = $this->_processExtends($data$thisSection[self::EXTENDS_NAME]$config);
            }
            unset($thisSection[self::EXTENDS_NAME]);
        }

        $config = $this->_arrayMergeRecursive($config$thisSection);

        return $config;
    }

    /** * Replace any constants referenced in a string with their values * * @param string $value * @return string */
    protected function _replaceConstants($value)
    {
Home | Imprint | This part of the site doesn't use cookies.