2010-10-05 234 views
0

這裏是專業人士的快速:PHP多維數組

如何顯示值1,2,3等,因爲它在它的第三個數組?

$meta_boxes = array 

    (
     "checkbox" => array 
     (
       "name" => "checkbox", 
       "title" => "", 
       "description" => "This is an example of a checkbox field.", 
       "type" => "checkbox", 
       "rows" => "", 
       "width" => "", 
       "options" => array 
       (
        "1" => "Value 1", 
        "2" => "Value 2", 
        "3" => "Value 3" 
      ) 
), 

回答

2

$meta_boxes['checkbox']['options']['1']會給你字符串「值1」從數組,然後你可以做任何你想用該值。

您現在應該能夠弄清楚如何訪問其他兩個。

3
$str = ''; 
foreach($meta_boxes['checkbox']['options'] as $k => $v) { 
    $str .= $v . "\n"; 
}