我使用這個代碼,但如果我用array_push()
它,我用array_push
陣列爲什麼我不需要在關聯數組中使用array_push?
foreach ($_POST['record_num'] as $check_rec_num) {
if(!in_array($check_rec_num, $_SESSION['selected_record'][$pageno])) {
array_push($_SESSION['selected_record'][$pageno][], $check_rec_num);
}
}
在輸入值插入值與null
但是當我使用此它被在陣列中自動添加值,沒有使用array_push
這是爲什麼呢?
foreach ($_POST['rec_num'] as $check_rec_num) {
if(!in_array($check_rec_num, $_SESSION['selected_record'][$pageno])) {
$_SESSION['selected_record'][$pageno][] = $check_rec_num;
}
}
第一示例
Array ([1] => Array ([0] => 36 [1] => 35) [2] =>)
第二例(無條括號)
Array ([1] => Array ([0] => 36 [1] => 35 [2] => 34) [2] => Array ([0] =>))
陣列設計第三實施例不使用array_push
如何地獄它是在末尾標註的值沒有array_push
的陣列?
Array (
[1] => Array (
[0] => 36
[1] => 35
)
[2] => Array (
[0] => 33
[1] => 32
)
)
羅,返回我空值 – 2013-02-15 17:49:39
@CreepyFrog索引這是因爲你還沒有定義'$ _SESSION ['selected_record'] [$ pageno]'作爲一個數組。 – Antony 2013-02-15 17:54:50
我是否需要先將數組推到數組中? – 2013-02-15 18:00:25