RE: [PHP] Referencing Multi Dimensional Arrays
| From: | Robinson, Matthew | Date: | Wed, 01 Dec 2004 17:31:07 +0000 |
| Subject: | RE: [PHP] Referencing Multi Dimensional Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203235@lists.php.net to get a copy of this message | ||
lol, perhaps embedded a bit too deep in my pre-amble. My question is
simply what's a good way to reference a given array entry when you don't
know where it is or how deep the array is. I can do a multi dimensional
array search and return an array of keys to locate the item, I then want
to use that array of keys to be able to reference the data to perhaps do
work on it ie:
The array is a collection of network data that can consist of address
allocation entries or other networks which can contain either more
networks or allocations. I call my search function to locate a
particular network which returns me an array of keys to locate that
entry. I then want to pass that to another function to actually work on
the data.
I have a search function:
$search_result = multi_array_search($net_array,"needle");
now search_result equals an array of keys to locate the needle, this is
variable in count.
Sometimes the array of keys is 3 entries other times 5, I want a way of
taking those entries and being able to do something like:
$net_array[multi-dimensional-key] = value;
where sometimes it might be in longhand:
$net_array["net1"]["net2"]["address1"]
or other times:
$net_array["net1"]["address1"]
but you don't know how deep you're going until the search returns you
the keys.
Hope that clears things a bit!
Kind regards
Matthew
-----Original Message-----
From: Jason Wong [mailto:php-general@gremlins.biz]
Sent: 01 December 2004 17:23
To: php-general@lists.php.net
Subject: Re: [PHP] Referencing Multi Dimensional Arrays
Sorry if I missed it, what was the question?
________________________________________________________________________
This message has been checked for all known viruses by the
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it
___