首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

请教一下该怎么解析出这个数组呢?多谢了

2013-10-07 
请问一下该如何解析出这个数组呢?谢谢了。Array([doctorDate] Array([0] Array([doctorOfDate] 20

请问一下该如何解析出这个数组呢?谢谢了。


Array
(
    [doctorDate] => Array
        (
            [0] => Array
                (
                    [doctorOfDate] => 2013-10-02
                    [orderingCount] => 12
                )
 
            [1] => Array
                (
                    [doctorOfDate] => 2013-10-03
                    [orderingCount] => 8
                )
 
        )
 
)


[解决办法]
假设数组名为:test
test['doctorDate'][0]['doctorOfDate']=2013-10-02
test['doctorDate'][0]['orderingCount']=12
test['doctorDate'][1]['doctorOfDate']=2013-10-03
test['doctorDate'][1]['orderingCount']=8
这个数组的定义是:

    test=array('doctorDate'=>
                    array(0=>array('doctorDate'=>'2013-10-02',
                                'orderingCount'=>12),
                          1=>array('doctorDate'=>'2013-10-03',
                                'orderingCount'=>8)
                           )
               )

[解决办法]
<?php
$test=array('doctorDate'=>
                    array(0=>array('doctorDate'=>'2013-10-02',
                                'orderingCount'=>12),
                          1=>array('doctorDate'=>'2013-10-03',
                                'orderingCount'=>8)
                           )
               );

foreach ($test as $arr)
{
foreach ($arr as $value)
{
echo $value['doctorDate'].'   '.$value['orderingCount'].'<br>';

}

}

?>

热点排行