Please help me a lot. Questions about merging session arrays in PHP

Source: Internet
Author: User
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 ();
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.