How basic syntax adds elements to the session array

Source: Internet
Author: User
Ask a very weak basic grammar.
If it is an ordinary array, we can do this:
$arr =array (); $arr []= "1"; $arr []= "2";p Rint_r ($arr);//This enables the purpose of adding elements to the $arr array


The problem is, if I define a session array:
$_session[' a ']=array ();//I want to add 1, 22 elements to an array of $_session[' a '], what should I say?


Reply to discussion (solution)

$a =array ("a", "B"); $_session["a"]= $a;  Print_r ($_session["a"]);

What's the difference?

$_session[' a ' [] = 1;$_session[' a ' [] = 2;

$_session[' a ']=array (); $_session[' a ' [] = 1;$_session[' a ' [] = 2;

$_session[' A '][]=1;$_session[' a '][]=2;

You're a two-dimensional array, and you're going to append the brackets in the back.

$_session[' a '][]= "xxx"

  • 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.