CreateDeepArray example

if ($line) {
                                @list($key$value) = explode(':', $line, 2);
                                if (substr($value, 0, 3) == '[{"') {
                                    if ($decoded = @json_decode($value, true)) {
                                        if (!empty($decoded) && (count($decoded) == 1)) {
                                            $value = $decoded[0];
                                        } else {
                                            $value = $decoded;
                                        }
                                    }
                                }
                                $thisfile_riff['guano'] = array_merge_recursive($thisfile_riff['guano'], getid3_lib::CreateDeepArray($key, '|', $value));
                            }
                        }

                        // https://www.wildlifeacoustics.com/SCHEMA/GUANO.html                         foreach ($thisfile_riff['guano'] as $key => $value) {
                            switch ($key) {
                                case 'Loc Position':
                                    if (preg_match('#^([\\+\\-]?[0-9]+\\.[0-9]+) ([\\+\\-]?[0-9]+\\.[0-9]+)$#', $value$matches)) {
                                        list($dummy$latitude$longitude) = $matches;
                                        $thisfile_riff['comments']['gps_latitude'][0]  = floatval($latitude);
                                        $thisfile_riff['comments']['gps_longitude'][0] = floatval($longitude);
                                        

    public static function CreateDeepArray($ArrayPath$Separator$Value) {
        // assigns $Value to a nested array path:         // $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')         // is the same as:         // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));         // or         // $foo['path']['to']['my'] = 'file.txt';         $ArrayPath = ltrim($ArrayPath$Separator);
        $ReturnedArray = array();
        if (($pos = strpos($ArrayPath$Separator)) !== false) {
            $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath$pos + 1)$Separator$Value);
        } else {
            $ReturnedArray[$ArrayPath] = $Value;
        }
        return $ReturnedArray;
    }

    /** * @param array $arraydata * @param bool $returnkey * * @return int|false */
Home | Imprint | This part of the site doesn't use cookies.