Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/301200-need-help-in-dimensional-array/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.