我使用$_POST
用於獲取所有input
值和它生成類似的數組:拆分PHP數組
[seen1] => 1
[flag1] => 0
[time1] => 275
[qtsnums1] => 17
[seen2] => 0
[flag2] => 0
[time2] => 0
[qtsnums2] => 11
[seen3] => 0
[flag3] => 0
[time3] => 0
[qtsnums3] => 9
[seen4] => 0
[flag4] => 0
[time4] => 0
[qtsnums4] => 5
[seen5] => 0
[flag5] => 0
[time5] => 0
[qtsnums5] => 10
我要拆分:
[seen1] => 1
[flag1] => 0
[time1] => 275
[qtsnums1] => 17
和在1個變量,插入如何做這個?
$output = array();
$wantedKeys = array('seen1', 'flag1', 'time1', 'qtsnums1');
foreach ($wantedKeys as $key)
{
$output[$key] = $input[$key];
}
print_r($output);
爲了獲取列表包含前四個按鍵,無論它們是如何命名的:
改說你的問題 –
@ rr-他想要做稱爲組塊的操作。 – Patashu
您是否需要在鍵中使用1,2,3後綴重組數組? – Jithin