SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Global arrays

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Global arrays

    can i declare an array global which retains its value throughout the session
    Please help me!
    Thnks in advance

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Yes, that is what $_SESSION is for.

    Page1.php
    PHP Code:
    <?php
    session_start
    ();
    $data = array('foo''bar''baz');
    $_SESSION['data'] = $data;
    // go to page 2
    Page2.php
    PHP Code:
    <?php
    session_start
    ();
    $data $_SESSION['data'];
    var_dump($data);
    it's probably easier to work in the $_SESSION superglobal directly though.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •