Heim > Backend-Entwicklung > PHP-Tutorial > PHP 二维数组的读出

PHP 二维数组的读出

WBOY
Freigeben: 2016-06-23 14:02:42
Original
1044 Leute haben es durchsucht

我有一个二组数组,如下:

Array ( [119] => Array (   [exclass_id] => 119     [exclass_name] => 模板1     [store_id] => 4     [sort_order] => 1     [exclass_time] => 1363059292     [chlid] => Array (       [0] => Array (         [express_exclassid] => 119         [express_way] => 3         [express_area] => 841         [express_one] => 1         [express_onprice] => 5.00         [express_two] => 1         [express_twprice] => 4.00         [express_time] => 1363059292       )       [1] => Array (         [express_exclassid] => 119         [express_way] => 1         [express_area] => 841,721,700         [express_one] => 1         [express_onprice] => 6.00         [express_two] => 1         [express_twprice] => 5.00         [express_time] => 1363059292       )       [2] => Array (         [express_exclassid] => 119         [express_way] => 3         [express_area] =>         [express_one] => 1         [express_onprice] => 10.00         [express_two] => 1         [express_twprice] => 5.00         [express_time] => 1363059292       )       [3] => Array (         [express_exclassid] => 119         [express_way] => 1         [express_area] =>         [express_one] => 1         [express_onprice] => 10.00         [express_two] => 1         [express_twprice] => 8.00         [express_time] => 1363059292       )       [4] => Array (         [express_exclassid] => 119         [express_way] => 2         [express_area] =>         [express_one] => 1         [express_onprice] => 20.00         [express_two] => 1         [express_twprice] => 10.00         [express_time] => 1363059292        )     )   )  ) 
Nach dem Login kopieren

后台的语句是:$model_express=&m('express');
foreach ((array)$exclass as $k=>$v){
$info = $model_express->getAll('select * from cc_express where express_exclassid='.$v['exclass_id']);
$exclass[$k]['chlid']=$info;


我前台的第一层是

再接着怎么写呢,初学PHP请大家指教一下!!


回复讨论(解决方案)

这不止二维吧。。。

冒似有4维了

也只能一层一层地读。

一层层怎么读出呢?

你每次循环,就读一次,之后在循环,在读一次,知道读取你想要的数据。

$foreach ($data as $dv){    foreach($dv as $v){        print_r($v);    }}
Nach dem Login kopieren
你试试。

你每次循环,就读一次,之后在循环,在读一次,知道读取你想要的数据。PHP code?12345$foreach ($data as $dv){ foreach($dv as $v){ print_r($v); }}你试试。 手误~~~

foreach ($data as $dv){    foreach($dv as $v){        print_r($v);    }}
Nach dem Login kopieren

  
显然是在 Smarty 中,不知道的就不要误导了

自己解决了
第一层   

第二层  

就可以了,结帖

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage