-2
我試圖讓我基本上進入季節如冬季或春季,然後裏顯示在那個賽季在上case.I幾個月我目前得到錯誤(T_CONSTANT_ENCAPSED_STRING)工作PROGRAMM PHP和我不知道從哪裏去這裏。任何幫助謝謝我怎樣才能得到呼應季月
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
//THE ARRAYS
$seasons = array('winter','spring','summer','autumn');
//MAKE THE CHARACTERS LOWER CASE OR HIGER CASE
$season = (isset($_POST['season']) && $_POST['season'] != "") ? strtolower($_POST['season']) : '';
//in_array — Checks if a value exists in an array
if($season && in_array($season, $seasons)){
$months = array();
//keyvalue table
$month_name = array(
1 => "January",
2 => "February",
3 => "March",
4 => "April",
5 => "May",
6 => "June",
7 => "July",
8 => "Auguest",
9 => "September",
10 => "October",
11 => "November",)
//keyvalue table connected with seasons
'winter' => array(1,2,11,12),
'spring' => array(3,4),
'summer' => array(5,6,7),
'autumn' => array(8,9,10),
if $season=> winter echo 1,2,11,12;
}
}else{
echo "Invalid season entered";
}
在'「November」後面用分號關閉'$ month_name'行)'和分號而不是逗號在結尾季節數組行 – fusion3k
您的腳本中存在太多錯誤(「'winter'=> array ','$ season => winter' ...)。我想你必須先看看[php基礎知識](http://php.net/manual/en/langref.php),然後再繼續。 – fusion3k