关于数组内部数组的PHP数组帮助

时间:2016-05-17 13:39:29

标签: 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 
        ) 
    ) 

当我尝试打印时......但是没有"项目"

    $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')));

我该怎么做?

1 个答案:

答案 0 :(得分: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/>";
    }
}