概要
閲覧数:1092
投稿日:2013-09-15
更新日:2013-09-15
多次元配列を新規作成
コード
function getItems(){ $items = array();//配列の初期化 $items[] = array( "id" => 1, "name" => "JavaScript", "menu1" => 1, "impression" => "分からない", ); $items[] = array( "id" => 2, "name" => "PHP", "menu1" => 2, "impression" => "JavaScriptよりは、分かる", ); $items[] = array( "id" => 5, "name" => "Ruby", "menu1" => 2, "impression" => "分かるはずがない", ); return $items; } $data = getItems(); print_r($data);
結果
Array ( [0] => Array ( [id] => 1 [name] => JavaScript [menu1] => 1 [impression] => 分からない ) [1] => Array ( [id] => 2 [name] => PHP [menu1] => 2 [impression] => JavaScriptよりは、分かる ) [2] => Array ( [id] => 5 [name] => Ruby [menu1] => 2 [impression] => 分かるはずがない ) )