For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > April 2004 > second array level









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author second array level
Reimar Bauer

2004-04-27, 1:55 pm

Dear all


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

At the moment I am doing something like this.


$subset=$ini_array["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 Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
-------------------------------------------------------------------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/..._lib_intro.html
========================================
===========================
Terence

2004-04-28, 11:53 pm

Reimar Bauer wrote:

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


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

OR

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

will do it.

see
http://www.php.net/manual/en/langua...s.increment.php

and
http://www.php.net/manual/en/language.types.array.php
see the third example of how to access an item from a multi-dimensional
array directly.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com