I'm trying to make a function that gets a list of files from a directory, adds them and their names + extensions as elements of an array, and returns the array (the array's name is also set as a parameter in the function. This is what I have so far:
function dirList($dir, $name) {
if(!$name || !$dir) { return false; }
if(!is_dir($dir)) {
$dir=substr($dir,0,(strlen($dir)-strrpos($dir,"/")));
} if(!is_dir($dir)) { return false; }
if($handler=opendir($dir)) {
$$name=array();
$count=0;
while(($file=readdir($handler))!==false) {
$$name[$count]=array(
'type' => substr($file,strrpos($file,'.')+1),
'name' => $file,
'href' => $dir.$file);
$count++;
}
} else {
return false;
}
return $$name;
}
But when I try to access it with:
$col1List=dirList($dir1, 'col1List');
if($col1List !== false) {
echo "<table class='view-col' id='view-col-1'>";
foreach($col1List as $num => $key) {
echo "<td>".$col1List[$num]['name']."</td>";
}
echo "</table>";
}
I simply get nothing. Well, I know that it's not stopping at 'if($col1List !== false) because the table is being echoed, but it seems that the loop adding files to the array simply isn't working.
Any help is much appreciated 
Fela