2014-10-10 54 views
-2

我將如何能夠從這個數組中回顯值?如何從這個數組中獲取回顯這些值?

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." 
    } 
} 

非常感謝您提供的任何幫助。

+0

出於測試目的? 'print_r()'...否則:你能詳細說一下嗎? – 2014-10-10 19:00:19

+0

你可以使用[foreach構造](http://php.net/manual/en/control-structures.foreach.php) – 2014-10-10 19:01:38

回答

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

這應該打印你的價值!

<?php 

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

?>