我有36個複選框......我用這個叫他們。 這樣標記。變量= =數組的特定部分
<input type='checkbox' value='1' name='ck[]'>
這樣調用
$checks = $_POST['ck']
$vars = array(
'ck1' => 'Demo',
'ck2' => 'Demo2',
'ck3' => 'Demo3',
'ck4' => 'Demo4',
'ck5' => 'Demo5',
'ck6' => 'Demo6',
'ck7' => 'Demo7',
'ck8' => 'Demo8',
'ck9' => 'Demo9',
'ck10' => 'Demo10',
);
foreach($vars as $key=>$default) {
$checks[$key] = !empty($checks[$key]) ? $default : '';
}
我現在如何才能使其中2個新的變量=從該職位的細節。 例如,
$CH1 = checks[1] - checks[6];
$ch2 = checks[6] - checks[10];
然後,
我怎麼能做出是否有$CH1
號將列出,並打破它在那裏..這樣
$checks[1] . '<br>' . $checks[2] and so on....
UPDATE ***
$vars = array(
'1' => 'Desktop',
'2' => 'Laptop Only',
'3' => 'Laptop/Dock',
'4' => 'Laptop Case',
'5' => 'Desk Phone',
'6' => 'Monitor',
'7' => 'Printer Access',
'8' => 'Printer - Personal',
'9' => 'Email(phone)',
'10' => 'Office 365',
'11' => 'Sharepoint',
'12' => 'Fax Fwd',
'13' => 'Adobe DC',
'14' => 'Apacheta',
'15' => 'Brightree',
'16' => 'TeamDME',
'17' => 'DirectView',
'18' => 'RingCentral',
'19' => 'Faxage',
'20' => 'Google Docs',
'21' => 'Badge Access',
'22' => 'Title Plate',
'23' => 'Bis Cards',
'24' => 'Travel',
'25' => 'Exp Reports',
'26' => 'Order Pads',
'27' => 'Demo Trilogy',
'28' => 'Stickers',
'29' => 'APS',
'30' => 'CBSS',
'31' => 'Conexis',
'32' => 'Evenfy',
'33' => 'Inventory',
'34' => 'AMEX',
'35' => 'Fuel Card',
'36' => 'Vehicle'
);
foreach($vars as $key=>$default) {
$checks[$key] = !empty($checks[$key]) ? $default : '';
}
當我回顯$檢查,它只是說數組.. ..不顯示任何n名單被檢查。
你不能使用'print_r($ checks)'或'var_dump($ checks)'來回顯數組。 – Barmar