有選擇表格後,如:檢查數組是否存在?
<select name="option[color][0]">
<select name="option[color][1]">
// option[color][2] isnt posted
有些產品不必須是選擇,然後當我嘗試從後得到他們,如果選擇每次不貼,即時得到錯誤,如:
未定義抵消:2
如何檢查,如果事情被貼? 嘗試:
$ids = $_POST['id'];
$option = $_POST['option'];
foreach ($ids as $key => $id)
{
//Undefined offset: 2
if($option['color'][$key])
{
$_SESSION[$key]['option']['color'] = $option['color'][$key];
}
//Undefined offset: 2
if(!empty($option['color'][$key]))
{
$_SESSION[$key]['option']['color'] = $option['color'][$key];
}
//Undefined offset: 2
if(isset($option['color'][$key]))
{
$_SESSION[$key]['option']['color'] = $option['color'][$key];
}
//... etc
}
等....什麼都我試試看,有錯誤:( 請幫
終於......謝謝:) – Bobo 2012-04-27 13:18:06