protected function add_missing_sub($grouped, $path, $tags) {

        // Remember tag being processed
        $processedtag = basename($path);

        $info =& $this->currentdata[$grouped]['tags'];
        $hierarchyarr = explode('/', str_replace($grouped . '/', '', $path));

        $previouselement = '';
        $currentpath = '';

        foreach ($hierarchyarr as $index => $element) {

            $currentpath = $currentpath . '/' . $element;

            // If element is already set and it's not
            // the processed one (with tags) fast move the $info
            // pointer and continue
            if ($element !== $processedtag && isset($info[$element])) {
                $previouselement = $element;
                $info =& $info[$element];
                continue;
            }

            // If previous element already has occurrences
            // we move $info pointer there (only if last is
            // numeric occurrence)
            if (!empty($previouselement) && is_array($info) && count($info) > 0) {
                end($info);
                $key = key($info);
                if ((int) $key === $key) {
                    $info =& $info[$key];
                }
            }

            // Create element if not defined
            if (!isset($info[$element])) {
                // First into last element if present
                $info[$element] = array();
            }

            // If element is the current one, add information
            if ($element === $processedtag) {
                $info[$element][] = $tags;
            }

            $previouselement = $element;
            $info =& $info[$element];
        }
    }
protected function add_missing_sub($grouped, $path, $tags) {

        // Remember tag being processed
        $processedtag = basename($path);

        $info =& $this->currentdata[$grouped]['tags'];
        $hierarchyarr = explode('/', str_replace($grouped . '/', '', $path));

        $previouselement = '';
        $currentpath = '';

        foreach ($hierarchyarr as $index => $element) {

            $currentpath = $currentpath . '/' . $element;

            // If element is already set and it's not
            // the processed one (with tags) fast move the $info
            // pointer and continue
            if ($element !== $processedtag && isset($info[$element])) {
                $previouselement = $element;
                $info =& $info[$element];
                continue;
            }

            // If previous element already has occurrences
            // we move $info pointer there (only if last is
            // numeric occurrence)
            if (!empty($previouselement) && is_array($info) && count($info) > 0) {
                end($info);
                $key = key($info);
                if ((int) $key === $key) {
                    $info =& $info[$key];
                }
            }

            // Create element if not defined
            if (!isset($info[$element])) {
                // First into last element if present
                $info[$element] = array();
            }

            // If element is the current one, add information
            if ($element === $processedtag) {
                $info[$element][] = $tags;
            }

            $previouselement = $element;
            $info =& $info[$element];
        }
    }
protected function add_missing_sub ( $ grouped , $ path , $ tags ) { // Remember tag being processed $ processedtag = basename ( $ path ) ; $ info = & $ this -> currentdata [ $ grouped ] [ 'tags' ] ; $ hierarchyarr = explode ( '/' , str_replace ( $ grouped . '/' , '' , $ path ) ) ; $ previouselement = '' ; $ currentpath = '' ; foreach ( $ hierarchyarr as $ index => $ element ) { $ currentpath = $ currentpath . '/' . $ element ; // If element is already set and it's not // the processed one (with tags) fast move the $info // pointer and continue if ( $ element !== $ processedtag && isset ( $ info [ $ element ] ) ) { $ previouselement = $ element ; $ info = & $ info [ $ element ] ; continue ; } // If previous element already has occurrences // we move $info pointer there (only if last is // numeric occurrence) if ( ! empty ( $ previouselement ) && is_array ( $ info ) && count ( $ info ) > 0 ) { end ( $ info ) ; $ key = key ( $ info ) ; if ( ( int ) $ key === $ key ) { $ info = & $ info [ $ key ] ; } } // Create element if not defined if ( ! isset ( $ info [ $ element ] ) ) { // First into last element if present $ info [ $ element ] = array ( ) ; } // If element is the current one, add information if ( $ element === $ processedtag ) { $ info [ $ element ] [ ] = $ tags ; } $ previouselement = $ element ; $ info = & $ info [ $ element ] ; } }
Add non-existing subarray elements
Add non - existing subarray elements