gmc1103 Posted May 17, 2016 Share Posted May 17, 2016 Hi I have an array who inside have another one This is how it is printed Array ( [0] => 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 ) [num] => 1 ) ) And when i try to tup this in a pdf, the last array can't be printed This is my code foreach ($result as $row){ $reservationID = $row['idreserva']; if(!isset($reservationsAry[$reservationID])) { $reservationsAry[$reservationID]['idreserva'] = $row['idreserva']; $reservationsAry[$reservationID]['sala'] = $row['sala']; $reservationsAry[$reservationID]['data'] = $row['data']; $reservationsAry[$reservationID]['inicio'] = $row['inicio']; $reservationsAry[$reservationID]['fim'] = $row['fim']; $reservationsAry[$reservationID]['equip1'] = $row['equip1']; $reservationsAry[$reservationID]['equip2'] = $row['equip2']; $reservationsAry[$reservationID]['atividade'] = $row['atividade']; $reservationsAry[$reservationID]['usernome'] = $row['usernome']; $reservationsAry[$reservationID]['items'] = array(); } //Adiciona os equipamentos $reservationsAry[$reservationID]['items'][] = ' '.$row['equip1'].' ; '.$row['equip2'].' '; } foreach($reservationsAry as $reservationID => $reservation) { $ixx = $ixx + 1; $data_chegada[] = array_merge($reservation, array('num' => $ixx)); print_r($data_chegada); } } And use this line to print the pdf $pdf->ezTable($data_chegada, $titles, '', $parametros_adicionales); All fields are printed but not "items" Any help? Quote Link to comment https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/ Share on other sites More sharing options...
Jacques1 Posted May 17, 2016 Share Posted May 17, 2016 Are you sure that your ezTable() method can handle nested arrays? Quote Link to comment https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/#findComment-1533035 Share on other sites More sharing options...
gmc1103 Posted May 17, 2016 Author Share Posted May 17, 2016 Hi Jacques I don't know, but it is possible to create another array to manage that? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/#findComment-1533036 Share on other sites More sharing options...
Jacques1 Posted May 17, 2016 Share Posted May 17, 2016 It's hard to tell without knowing the exact library. How do you even want the items to be displayed? One per line? As bullet points? As something else? Quote Link to comment https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/#findComment-1533038 Share on other sites More sharing options...
gmc1103 Posted May 17, 2016 Author Share Posted May 17, 2016 Hi Jacques I have managed to put it working doing this $reservationsAry[$reservationID]['items'] = ' '.$row['equip1'].' ; '.$row['equip2'].' '; instead of creating another array $reservationsAry[$reservationID]['items'] = array(); Now it is working, i don't know if it is the best approach but it is working What do you thing? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/#findComment-1533040 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.