平成29年9月10日(日曜日)
How to declare a two dimensional array most easily in PHP?
// $array = array( 0 => array( 'name' => 'John Doe', 'email' => 'john@example.com' ), 1 => array( 'name' => 'Jane Doe', 'email' => 'jane@example.com' ), ); //
// $array = array(); $array[0] = array(); $array[0]['name'] = 'John Doe'; $array[0]['email'] = 'john@example.com'; $array[1] = array(); $array[1]['name'] = 'Jane Doe'; $array[1]['email'] = 'jane@example.com'; //
// $array = array(); $array["Type"] = "土砂災害"; $array["WarningPeriod"]["EndTime"]["Date"] = '1日'; $array["WarningPeriod"]["EndTime"]["Term"] = '夜遅く'; $array["AdvisoryPeriod"]["EndTime"]["Date"] = '2日'; $array["AdvisoryPeriod"]["EndTime"]["Term"] = '明け方'; $array["AdvisoryPeriod"]["OverTime"] = 'にかけて 以後も続く'; echo $array["AdvisoryPeriod"]["OverTime"]; //
/* //---------------------------------- $array = array( "Type" => "土砂災害", "WarningPeriod" => array( 'EndTime' => array( 'Date' => '1日', 'Term' => '夜遅く', ), 'StartTime' => array( 'Date' => '1日', 'Term' => '夜遅く', ), 'OverTime' => 'にかけて 以後も続く' ), "AdvisoryPeriod" => array( 'EndTime' => array( 'Date' => '1日', 'Term' => '夜遅く', ), 'StartTime' => array( 'Date' => '1日', 'Term' => '夜遅く', ), 'OverTime' => 'にかけて 以後も続く' ), ); */