www.webdeveloper.com
Results 1 to 3 of 3

Thread: php help

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    php help

    Hi Im new to php and trying to get an understanding of some of the syntax -
    I was hoping that someone could explain the following bits of code and what it does

    if (isset($_SESSION['somesession'][$somevariable])) {
    $items = $_SESSION['somesession'][$somevariable]; }

    I understand the isset method but I dont understand what this is supposed to do

    $_SESSION['somesession'][$somevariable]

    is it a concatenation or merge of somesort -

    any help would be greatly appreciated.

    Thanks

    Tim

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    It specifies one element of a 2-dimension array.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2012
    Location
    Belgium
    Posts
    66
    $_SESSION['somesession'][$somevariable]

    ->is an array.

    $_SESSION['somesession'] is the array name
    [$somevariable] is the position in the array

    example:

    <?php
    session_start();
    $A = array();
    $name = "name";
    $A[$name] = "something";
    $_SESSION['test'] = $A;
    print ($_SESSION['test'][$name]);
    //prints "something";
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles