我有一個日曆做。用戶選擇他/她想要阻止的日子。在數據庫中,將它們保存爲與節日的名稱的數組:PHP回聲變量時,我不知道哪些是要告訴
a:3:{i:0;s:6:"easter";i:1;s:12:"thanksgiving";i:2;s:9:"christmas";}
在文件中,我有每個人的日期字符串:
$thanksgiving = "
[11, 27, 2014],
[11, 26, 2015],
[11, 24, 2016],
[11, 23, 2017],
[11, 22, 2018],
[11, 28, 2019],
[11, 26, 2020],
[11, 25, 2021],
[11, 24, 2022],
[11, 23, 2023]
";
$christmas = "
[12, 25, 2014],
[12, 25, 2015],
[12, 25, 2016],
[12, 25, 2017],
[12, 25, 2018],
[12, 25, 2019],
[12, 25, 2020],
[12, 25, 2021],
[12, 25, 2022],
[12, 25, 2023]
";
$fourthofjuly = "
[07, 04, 2015],
[07, 04, 2016],
[07, 04, 2017],
[07, 04, 2018],
[07, 04, 2019],
[07, 04, 2020],
[07, 04, 2021],
[07, 04, 2022],
[07, 04, 2023]
";
等等
$blocked_holidays is the array retrieved from the DB
When I try to echo it:
$blocked_string = implode(", $", $blocked_holidays);
$blocked_string = "[ $" . $blocked_string . " ]";
echo $blocked_string;
I get: [ $newyears, $thanksgiving, $christmas ]
我怎樣才能得到它回聲的字符串的值?
如果我將其更改爲:
$$thanksgiving = "
[11, 27, 2014],
[11, 26, 2015],
[11, 24, 2016],
[11, 23, 2017],
[11, 22, 2018],
[11, 28, 2019],
[11, 26, 2020],
[11, 25, 2021],
[11, 24, 2022],
[11, 23, 2023]
";
$$christmas = "
[12, 25, 2014],
[12, 25, 2015],
[12, 25, 2016],
[12, 25, 2017],
[12, 25, 2018],
[12, 25, 2019],
[12, 25, 2020],
[12, 25, 2021],
[12, 25, 2022],
[12, 25, 2023]
";
$$fourthofjuly = "
[07, 04, 2015],
[07, 04, 2016],
[07, 04, 2017],
[07, 04, 2018],
[07, 04, 2019],
[07, 04, 2020],
[07, 04, 2021],
[07, 04, 2022],
[07, 04, 2023]
";
和
$blocked_string = implode(", $", $$blocked_holidays);
echo $$blocked_string;
呼應的日期,但只能從最近的可變的,不是所有的人。
嘗試檢出變量變量,$$變量 – 2014-11-23 23:29:38
無法正常工作。我確實找到了這個:http://php.net/manual/en/language.variables.variable.php,並試圖使其工作。我得到的最接近,它只會顯示最後一個變量字符串。 – Christian 2014-11-23 23:35:24
檢查編輯..這是我在變量變量的嘗試。 – Christian 2014-11-23 23:51:30