如何从这个数组中回显这些值?

时间:2014-10-10 18:57:30

标签: php html

我如何能够回显这个数组中的值?

array(2) {
  [0]=>
  array(3) {
    ["task_id"]=>
    string(1) "2"
    ["task_title"]=>
    string(15) "The Second Task"
    ["task_description"]=>
    string(41) "Pretty much the same as the first task..."
  }
  [1]=>
  array(3) {
    ["task_id"]=>
    string(1) "1"
    ["task_title"]=>
    string(9) "Test Task"
    ["task_description"]=>
    string(35) "This is a description for the task."
  }
}

非常感谢您提供的任何帮助。

2 个答案:

答案 0 :(得分:1)

试试这个

$array=array(
    array(
    "task_id"=> "2",
    "task_title"=>"The Second Task",
    "task_description"=> "Pretty much the same as the first task..."
  ),
  array( 
    "task_id"=>"1",
    "task_title"=>"Test Task",
    "task_description"=>"This is a description for the task."
  )
);
echo $array[0]['task_id'];

或试试这个

  foreach($array as $key=>$value){
      foreach($value as $k=>$v){
           echo $v . "<br/>";
      }
   }

答案 1 :(得分:1)

这应该可以打印你的价值观!

<?php

  foreach ($array as $innerArray)
    foreach ($innerArray as $value)
        echo $value;

?>