2016-05-17 45 views
1

有人可以解釋我怎樣才能看到我的「物品」?有關陣列內陣列的PHP數組幫助

這是我的數組

Array ( 
    [idreserva] => 703 
    [sala] => 7 - INF 
    [data] => 2016-05-28 
    [inicio] => 21:00:00 
    [fim] => 23:30:00 
    [equip1] => Leitor/CD/ USB 
    [equip2] => Projetor 
    [atividade] => 
    [usernome] => xxxxx 
    [items] => Array ( 
     [0] => Leitor/CD/ USB; Projetor 
     ) 
    ) 

當我嘗試print..eveything來,但沒有 「項目」

$titles = array(
     'sala' => '<b>Sala</b>', 
     'usernome' => '<b>Docente</b>', 
     'data' => '<b>Data</b>', 
     'inicio' => utf8_decode('<b>Início</b>'), 
     'fim' => '<b>Fim</b>', 
     'items' =>utf8_decode('<b>Equipamento</b>') 
    ); 

$parametros_adicionales = array(
     'width'=>570, 
     'showHeadings'=>1, 
     'fontSize' => 9, 
     'colGap'=>2, 
     'xPos' => 'center', 
     'xOrientation'=>'center', 
     'cols'=>array(
     "sala" => array('justification'=>'center', 'width' => '100'), 
     "usernome" => array('justification'=>'center', 'width' => '200'), 
     "data" => array('justification'=>'center', 'width' => '80'), 
     "inicio" => array('justification'=>'center', 'width' => '60'), 
     "fim" => array('justification'=>'center', 'width' => '60'), 
     "items" => array('justification'=>'center', 'width' => '150'))); 

我該怎麼辦呢?

+0

其實你正在試圖achieve.Your的解釋是不夠的。 –

+0

我想要在我的pdf中有「項目」...我有所有的領域,但我沒有這一個,並通過print_r我有「項目」,所以爲什麼$ parametros_adicionales =數組()沒有得到「項目」字段? – gmc1972

+0

嘗試刪除項目數組中的分號 – jophab

回答

0

在下面的代碼我打印您陣列的所有孩子的:

foreach($parametros_adicionales as $key => $value) 
{ 
    if(count($value) > 1) 
    { 
     echo "$key <br/>"; 
     foreach($value as $key2 => $value2) 
     { 
      if(count($value) > 1) 
      { 
       echo "- $key2 <br/>"; 
       foreach($value2 as $key3 => $value3) 
       { 
        echo "-- $key3 = $value3 <br/>"; 
       } 
      } 
      else 
      { 
       echo "- $key2 = $value2 <br/>"; 
      } 
     } 
    } 
    else 
    { 
     echo "$key = $value <br/>"; 
    } 
} 
+0

是不是......我的sql返回此; 「{ idreserva: 「577」, 薩拉: 「35」, 數據: 「2016年5月17日」, INICIO: 「8點15分00秒」, FIM: 「九時45分00秒」, equip1:「Projetor」, equip2:null, atividade:null, usernome:「xxxxxx」, items:[ 「Projetor; Teste「 ] },你可以看到項目是一個數組,但我不能把它放在我的pdf – gmc1972