2015-06-08 74 views
0

我有這樣的結果,我想分析和關注我的成績得到Lfam例如:如何創建表包含此結果?

> > > object(stdClass)[159] 
> >  public 'PapFamType' => 
> >   array (size=28) 
> >   0 => 
> >    object(stdClass)[164] 
> >    public 'Owner' => string '' (length=0) 
> >    public 'Fam' => string 'CMM' (length=3) 
> >    public 'Lfam' => string 'Couché moderne 
> 
> mat' (length=19) 
>    public 'Ctype' => string 'CM5' (length=3) 
>    public 'Ltype' => string 'Chromomat' (length=9) 
>    public 'Ccoul' => string 'BC' (length=2) 
>    public 'Lcoul' => string 'BLANC' (length=5) 
>    public 'Gramm' => string '400' (length=3) 
>    public 'PoidsM' => string '0' (length=1) 
>    
>   1 => 
>    object(stdClass)[165] 
>    public 'Owner' => string '' (length=0) 
>    public 'Fam' => string 'CMM' (length=3) 
>    public 'Lfam' => string 'Couché Moderne Mat' (length=19) 
>    public 'Ctype' => string 'CM5' (length=3) 
>    public 'Ltype' => string 'Chromomat' (length=9) 
>    public 'Ccoul' => string 'IV' (length=2) 
>    public 'Lcoul' => string 'IVOIRE NATUREL' (length=14) 
>    public 'Gramm' => string '250' (length=3) 
>    public 'PoidsM' => string '0' (length=1) 

我如何解析這個結果呢?

我搜索了,但我沒有發現我怎麼能做到這一點。 我怎樣才能把結果表

oreach($GetJobResult->Components->Component as $component_index=>$component) { 
       $quote_title= ($component_index+1).') '.$component->Title."\n"; 
       //var_dump($component_index+1); 
       //die(); 

       if(isset($component->Paper->Family)) { 
        if(isset($component->Paper->Type) && isset($component->Paper->Color)) { 


         $getPaperInfoResult=$ws->getPaperInfo($component->Paper->Family,$component->Paper->Type); 

         $quote_desc = $getPaperInfoResult->PapFamType[$component_index+1]->Lfam.' - '.$getPaperInfoResult->PapFamType[$component_index+1]->Lcoul.' - '.$getPaperInfoResult->PapFamType[$component_index+1]-> Gramm.' g/m2'."\n"; 
         var_dump($quote_desc); 
        } 
       } 
      } 

感謝

+0

的陣列爲什麼這個標記XML和SimpleXML?我在這裏只看到一個普通的PHP對象。 – IMSoP

回答

0

PapFamType是對象

<?php 
foreach ($getPaperInfoResult->PapFamType as $papFamType) { 
    foreach ($papFamType as $attr => $value) { 
     // Attr Owner => value: 
     // Attr Fam => value: CMM 
     echo sprintf('Attr %s => value: %s', $attr, $value); 
    } 
}