On 15-04-2009 at 12:16:53 Urša Baričević <uba...@gmail.com> 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);


--
regards, Kornel



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

Reply via email to