Welcome Guest, Not a member yet? Register   Sign In
Using function directory_map
#11

[eluser]Colin Williams[/eluser]
Just note that my use of the static variable $paths is probably not the most elegant solution (try calling the function twice... yeah). I would suggest rethinking this before you use it heavily!

==== UPDATE =============================================================

Okay.. here's a better function. I had nothing else to do. It is sad, really:

Code:
function directory_map_paths($wp = '', $map = array())
{
   $paths = array();
   if (!is_array($map) or !count($map))
   {
      if ($wp)
      {
         $map = directory_map($wp);
         $wp = '';
      }
      else
      {
         show_error('No map or working path given to remap.');
      }
   }
   if (count($map))
   {
      foreach ($map as $k => $v)
      {
         if (is_array($v))
         {
            $paths = array_merge($paths, directory_map_paths($wp . ($wp ? '/' : '') . $k, $v)); // Recurse
         }
         else
         {
            $paths[] = $wp . ($wp ? '/' : '') . $v;
         }
      }
   }
   return $paths;
}


Messages In This Thread
Using function directory_map - by El Forum - 07-20-2008, 06:00 PM
Using function directory_map - by El Forum - 07-20-2008, 08:27 PM
Using function directory_map - by El Forum - 07-21-2008, 01:05 AM
Using function directory_map - by El Forum - 07-21-2008, 01:14 AM
Using function directory_map - by El Forum - 07-21-2008, 01:19 AM
Using function directory_map - by El Forum - 07-21-2008, 01:24 AM
Using function directory_map - by El Forum - 07-21-2008, 01:28 AM
Using function directory_map - by El Forum - 07-21-2008, 01:53 AM
Using function directory_map - by El Forum - 07-21-2008, 01:59 AM
Using function directory_map - by El Forum - 07-21-2008, 02:14 AM
Using function directory_map - by El Forum - 07-21-2008, 05:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB