Php 多维Judy数组

Php 多维Judy数组,php,arrays,json,judy-array,Php,Arrays,Json,Judy Array,我试图将Judy作为一个传统的php数组来使用,但我在尝试访问多维数组时遇到了麻烦。每次我尝试打印嵌套键值时,都会得到一个空值 我如何迭代我的结果 如何将此结构编码为json?每次我尝试,都会得到一个空括号“{}” 我的代码: /** * This method parses the content of XML body * Array of objects to spare more memory usage * @param $xml object SimpleXml Object

我试图将Judy作为一个传统的php数组来使用,但我在尝试访问多维数组时遇到了麻烦。每次我尝试打印嵌套键值时,都会得到一个空值

  • 我如何迭代我的结果
  • 如何将此结构编码为json?每次我尝试,都会得到一个空括号“{}”
  • 我的代码:

    /**
     * This method parses the content of XML body
     * Array of objects to spare more memory usage
     * @param $xml object SimpleXml Object
     * @param $timeRequest array this second param brings the time_request value along with the url
     */
    private function parseXmlContent($xml, $timeRequest)
    {
        $counter = 0;
        $forecast = new \Judy(Judy::INT_TO_MIXED);
    
        foreach ($xml->point as $key => $value):
    
            $forecast[$counter] = $this->initJudy($value, $timeRequest, count($value);            
            $counter++;
    
        endforeach;
    
        $this->sucess++;
        $this->results[$this->results->nextEmpty(0)] = $forecast;
    }
    
    private function initJudy($value, $timeRequest, $length)
    {
        $judy = new \Judy(Judy::STRING_TO_MIXED);
        $judy['timestamp'] = (string)$value->data[0];
        $judy['time_request'] = $timeRequest[0]->time_request;
        $judy['latitude'] = (string)$value->data[1];
        $judy['longitude'] = (string)$value->data[2];
    
        $j = 0;
        for ($i = 3; $i < $length; $i++) {
            $attribute = $this->variables[$j];
            $judy[$attribute] = (string)$value->data[$i];
            $j++;
        }
    
        return $judy;
    
    }
    
    /**
    *该方法解析XML正文的内容
    *对象数组以节省更多内存使用
    *@param$xml对象SimpleXml对象
    *@param$timeRequest数组此第二个参数带来时间请求值和url
    */
    私有函数parseXmlContent($xml,$timeRequest)
    {
    $counter=0;
    $forecast=new\Judy(Judy::INT\u TO\u MIXED);
    foreach($xml->pointas$key=>$value):
    $forecast[$counter]=$this->initJudy($value、$timeRequest、count($value);
    $counter++;
    endforeach;
    $this->sucess++;
    $this->results[$this->results->nextentiy(0)]=$forecast;
    }
    私有函数initJudy($value、$timeRequest、$length)
    {
    $judy=new\judy(judy::STRING\u-TO\u-MIXED);
    $judy['timestamp']=(字符串)$value->data[0];
    $judy['time\u request']=$timeRequest[0]->time\u request;
    $judy['latitude']=(字符串)$value->data[1];
    $judy['longide']=(字符串)$value->data[2];
    $j=0;
    对于($i=3;$i<$length;$i++){
    $attribute=$this->variables[$j];
    $judy[$attribute]=(字符串)$value->data[$i];
    $j++;
    }
    退还$judy;
    }
    
    json_encode($this->results);
    或者任何你想作为json数据结构传递的东西,请看@riggsfully我改变了结构,现在我正在做一些事情:
    $judy[INT]=new judy(STRING_to_MIXED);
    使用json_encode函数返回一个空的
    {/code>results);
    或任何你想作为JSON数据结构传递的内容,请参见@RiggsFolly我更改了结构,现在我正在处理以下内容:
    $judy[INT]=new judy(STRING_to_MIXED);
    使用JSON_encode函数返回一个空的
    {}