On 2009-04-15 13:41, Kornel Lesiński wrote:
> On 15-04-2009 at 12:16:53 Urša Baričević wrote:
>
>> Hello,
>>
>> I have structure like this:
>> array(
>>     'gallery',
>>     'gallery/category,
>>     'gallery/category/subcategory1',
>>     'gallery/category/subcategory2',
>>     'gallery/category2/subcategory1',
>>     ....
>> );
>>
>> How to convert this structure to recursive array described in FAQ?
>
>
> $recursive = array();
>
> foreach($menu as $path)
> {
>   $current = &$recursive;
>   foreach(explode('/',$path) as $part)
>   {
>     if (!isset($current[$part])) $current[$part] = array();
>     $current = &$current[$part];
>   }
> }
>
> print_r($recursive);
>
>

Thank you Kornel
for your very quick response.

best wishes,
Urša Baričević

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to