if (isset($_POST['callSubmit'])) {
$vs = 25;
$callName = $_POST['callName'];
$callNumber = $_POST['callNumber'];
$cNumber = array();
for ($i = 0; $i <= $vs - 1; $i++) {
array_push($cNumber, array());
}
$cNumber[$callNumber - 1][] = $callName;
print_r($cNumber);
}
這追加數組是給我的輸出:多維PHP推
Array (
[0] => Array
(
)
[1] => Array
(
)
[2] => Array
(
)
[3] => Array
(
)
[4] => Array
(
)
[5] => Array
(
)
[6] => Array
(
[0] => Tested
)
[7] => Array
(
)
[8] => Array
(
)
[9] => Array
(
)
[10] => Array
(
)
[11] => Array
(
)
[12] => Array
(
)
[13] => Array
(
)
[14] => Array
(
)
[15] => Array
(
)
[16] => Array
(
)
[17] => Array
(
)
[18] => Array
(
)
[19] => Array
(
)
[20] => Array
(
)
[21] => Array
(
)
[22] => Array
(
)
[23] => Array
(
)
[24] => Array
(
)
)
這就是輸出的時候應該追加值,每次我提交表單。也許這是因爲表單提交時頁面刷新,這就是爲什麼數組被清空了?不知道,但如果任何人能告訴我爲什麼它這樣做的原因,如果我的表格被提交時,我的假設被清空,請讓我知道。
替代品總是被接受!
您是否在尋找[PHP會話(http://php.net/manual/en/book.session.php)? – Rudie
你爲什麼要推一個空的'array()'? –
因爲每個陣列都有它自己的值,並且它根據設置而變化。因此,基本上0 => [0] => 'A',[1] => 'B' 等 – RepeaterCreeper