10-11-2008, 02:58 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Apr 2008
Posts: 78
Thanks: 0
|
Thank you. I wasn't aware of that function and it did fix the sorting problem. But I am getting an error now. I changed my function as shown below.
PHP Code:
function GetStorageLocations($curDir, $store_locns, &$level)
{
$dirs = glob($curDir . '/*', GLOB_ONLYDIR);
$cur = 0;
foreach ($dirs as $dir)
{
$level++;
$dirShow = str_pad($dir, strlen($dir) + (int)$level, "-", STR_PAD_LEFT);
$store_locns[] = array('id' => $dir, 'text' => $dirShow);
$store_locns = GetStorageLocations($dir, $store_locns, $level);
}
$level--;
return $store_locns;
}
If I run it as shown, I get the error
Quote:
|
Warning: Invalid argument supplied for foreach() in...
|
The line it is failing at is
PHP Code:
foreach ($dirs as $dir)
If I change that line to
PHP Code:
foreach ((array)$dirs as $dir)
I don't get the error but there's no output either. Can someone please point out how to prevent that error or what I am doing wrong?
|
|
|
|