0
我正在使用cakePHP 2.2並想知道如何在此嵌套數組內輸出信息。顯示嵌套數組PHP
我試圖顯示[作業] =>數組& [兒童] =>數組內的數據。我已經提供了我當前的CakePHP代碼,可能有所幫助。
陣列輸出
[4] => Array
(
[Job] => Array
(
[id] => 20
[parent_id] => 0
[rght] => 6
[lft] => 1
[client_id] => tasd
[contact] => asdf
[email] => sdf
[address] =>
[lat] =>
[long] =>
[user_id] => 1
[request_type_id] => Electrical
[date_start] => 0000-00-00 00:00:00
[date_end] => 0000-00-00 00:00:00
[date_complete] => 0000-00-00 00:00:00
[date_closed] => 0000-00-00 00:00:00
[status] => open
[brief_desc] => aasdf
[desc] => asdfasdf
[cost_est] => 3434.00
[cost_actual] =>
[created] => 2011-12-18 20:39:24
[modified] => 2011-12-18 20:39:24
)
[Children] => Array
(
[0] => Array
(
[id] => 21
[parent_id] => 20
[rght] => 3
[lft] => 2
[client_id] => TEST3333
[brief_desc] => testsdf
[desc] => asdfasdfasdf
[cost_est] => 3434.00
[cost_actual] =>
[created] => 2011-12-18 20:42:13
[modified] => 2011-12-18 20:42:13
)
[1] => Array
(
[id] => 22
[parent_id] => 20
[rght] => 5
[lft] => 4
[client_id] => TEST666666
[brief_desc] => testsdf
[desc] => asdfasdfasdf
[cost_est] => 3434.00
[cost_actual] =>
[created] => 2011-12-18 20:42:43
[modified] => 2011-12-18 20:42:43
)
當前CakePHP的代碼:
<?php
foreach ($jobs as $job): ?>
<li><a href="/jobs/view/<?php echo h($job['Job']['id']); ?>">
<h3>J<?php echo h($job['Job']['id']); ?> - <?php echo h($job['Job']['brief_desc']); ? ></h3>
<p><?php echo h($job['Job']['desc']); ?></p>
<a href="/jobs/edit/<?php echo h($job['Job']['id']); ?>"></a>
</a>
<?php
?>
</li>
<?php endforeach; ?>
你可以清楚,什麼是你想實現..? – 2011-12-21 07:23:14
對不起,我已更新我的帖子,使其更清楚。 – AshHimself 2011-12-21 07:28:13
是否foreach循環無法正常工作..? – 2011-12-21 07:30:13