显示嵌套数组PHP

Ash*_*elf 0 php arrays cakephp

我正在使用cakePHP 2.2并想知道如何在这个nest数组中输出信息.

我试图在[Job] => Array&[Children] => Array中显示数据.我提供了我目前的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
                    )
Run Code Online (Sandbox Code Playgroud)

目前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; ?>
Run Code Online (Sandbox Code Playgroud)

Sud*_*oti 5

尝试:

foreach($jobs as $job) {
  echo $job['Job']['id'];
  foreach($job['Children'] as $child) {
     echo $child['id'];
  }
}