思いついたソース
ソースの解説
//$_SESSION['animal']を初期化
$_SESSION['animal'] = array();
//チェックボックスにチェックされていればtrue
foreach($_POST[animal] as $value){
$_SESSION['animal'][$value] = "true";
}
処理の前に$_SESSION[‘animal’]を空っぽに。
foreachを使ってcheckされた分だけ$_SESSION[‘animal’]に配列を確保してtrueを入れる.
チェックボックスを生成。
$_SESSION[‘animal’][ ]がtrueならチェックを付けます。
name = “animal[]”は配列でPHPに渡しますよーという意味です。
コメントを残す