Please greatly help, PHP in the session array merge problem!
Session_Start ();
$page =$_post[' page '; Pass back to page value for loop comparison
$pagestr = "P". $_post[' page '; Keywords that convert page values to character arrays
$pagecount =$_post[' PageCount '];
$idstr =$_post[' idstr '];
for ($i =1; $i <= $pagecount; $i + +) {
if ($i = $page) {
$_session[$i]=array ($pagestr = $idstr);
$_session[idstr]=array_merge ($_session[idstr],$_session[$i]);};
break;}; Loops and stores the check box information selected for each page in the array
$_session[total_idstr]=implode ("", $_session[idstr]); Converts an array to a string containing the information selected for all check boxes
Echo $_session[total_idstr];
?>
A session to get a check box, with a string as the key value P1 represents the first page, and then the first page of the selection of input into the array, in the format of p1=>1|2|, the problem in the merging of the array when no hair to get the corresponding value, echo did not output, do not know what is going on! Afraid of encountering the cycle of death, so in the loop to $i= $page jumped out!
The home computer executes completely without problems!
Unit of the computer same environment but can not output!
Solve ah, what problem!
Share to:
------Solution--------------------
if ($i = $page) {
should be for
if ($i = = $page) {
Posted results for Print_r ($_post) and Print_r ($_session)
------Solution--------------------
Session_Start ();
if (! isset ($_session[' idstr ')) $_session[' idstr '] = array ();