<?php
session_start();
if
(
$_POST
){
$_SESSION
[
'old'
]=
array
(
'one'
,
'two'
,
'three'
,
'four'
,
'five'
);
$_SESSION
[
'old'
]=
array
();
$_SESSION
[
'old'
]=
array
(
'two'
,
'five'
);
$new
=(
array
)
$_POST
[
'big'
];
foreach
(
$new
as
$k
=>
$v
){
if
(!in_array(
$v
,
$_SESSION
[
'old'
])){
$_SESSION
[
'old'
][]=
$v
;
echo
'add '
.
$v
;
echo
'<br />'
;
}
else
{
echo
'mod '
.
$v
;
echo
'<br />'
;
}
}
foreach
(
$_SESSION
[
'old'
]
as
$k
=>
$v
){
if
(!in_array(
$v
,
$new
)){
$id
=
array_keys
(
$_SESSION
[
'old'
],
$v
);
unset(
$_SESSION
[
'old'
][
$id
[0]]);
echo
'del '
.
$v
;
echo
'<br />'
;
}
}
echo
"<pre>"
;
print_r(
$_SESSION
[
'old'
]);
}
?>
<form method=
"post"
>
<input type=
"checkbox"
name=
"big[]"
value=
"one"
/> one<br />
<input type=
"checkbox"
name=
"big[]"
value=
"two"
/> two<br />
<input type=
"checkbox"
name=
"big[]"
value=
"three"
/> three<br />
<input type=
"checkbox"
name=
"big[]"
value=
"four"
/> four<br />
<input type=
"checkbox"
name=
"big[]"
value=
"five"
/> five<br />
<input type=
"submit"
value=
"submit"
name=
'abc'
>
</form>