Re: associative arrays
| From: | Rafael Mora | Date: | Tue, 02 Nov 2021 10:28:25 +0000 |
| Subject: | Re: associative arrays | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327806@lists.php.net to get a copy of this message | ||
hello!
What if you put fruit and nut into the arrays? Something like this:
$sampleArray = [];
$sampleArray['nuts'] = ['nuts'=>[treeNuts'=>'walnut']];
$sampleArray['fruit'] =
['fruit'=>['notUsuallyFruit'=>['tomatoe'=>true,
'avacado'=>true, 'eggplant'=>true]]];
Just guessing! Hope this helps!
On Tue, Nov 2, 2021 at 01:24 JEFFRY KILLEN <jekillen@prodigy.net> wrote:
> Hello:
>
> I have been programming php and javascript for some time.
> I have not come on a way to navigate upward in javascript
> objects (it does not have associative arrays but objects are
> often used in the same way associative arrays are used)
>
> I would like to find out if there is a way of navigating a
> multidimensional associate array upward: I.E.:
> From a child property/value to a parent property
>
> For instance:
>
> $sampleArray = [];
> $sampleArray['nuts'] = ['treeNuts'=>'walnut'];
> $sampleArray['fruit'] =
> ['notUsuallyFruit'=>['tomatoe'=>true,
> 'avacado'=>true, 'eggplant'=>true]];
>
> How would I get from 'tomatoe' to 'notUsuallyFruit', to 'fruit'
> and find
> 'nuts'? Is there a parent property implicit
> in associative arrays in php? I see next and prev in the manual under
> array functions. But I don't
> see anything that suggests moving upward to find a parent and parent
> syblings.
>
> I written lots of recursive code to search from the root to the tips of
> the branches.
>
> To create a metaphor: it is like a squirrel jumps from another tree and
> lands on a branch. It
> can find its way to the trunk and to the ground.
>
> Thank you for time and attention
> JK
--
----------------------------------------------
Atentamente/Best regards
Rafael Mora
Cel/Mob: +58-414-493.31.39
Cel/Mob: +57-321-755.37.69
Twitter @titanve