second array level

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reimar Bauer

    second array level

    Dear all


    How can I directly acces the second level of an array.

    At the moment I am doing something like this.


    $subset=$ini_ar ray["section"];
    $number=$subset["number"];


    I would like to increment number by 1 without storing the data in a
    different variable.
    ($ini_array["section"])["number"]




    Array
    (
    [section] => Array
    (
    [number] => 1
    )


    )

    regards

    Reimar


    --
    Reimar Bauer

    Institut fuer Stratosphaerisc he Chemie (ICG-I)
    Forschungszentr um Juelich
    email: R.Bauer@fz-juelich.de
    -------------------------------------------------------------------
    a IDL library at ForschungsZentr um Juelich

    =============== =============== =============== =============== =======
  • Terence

    #2
    Re: second array level

    Reimar Bauer wrote:
    [color=blue]
    > Dear all
    >
    >
    > How can I directly acces the second level of an array.
    >
    > At the moment I am doing something like this.
    >
    >
    > $subset=$ini_ar ray["section"];
    > $number=$subset["number"];
    >
    >
    > I would like to increment number by 1 without storing the data in a
    > different variable.
    > ($ini_array["section"])["number"]
    >[/color]

    $ini_array["section"]["number"]++;

    OR

    ++$ini_array["section"]["number"];

    will do it.

    see
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    and
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

    see the third example of how to access an item from a multi-dimensional
    array directly.



    Comment

    Working...