if(isset($list)) { $oldlist = $list; $list[$i] = $filename; $list = array_merge($oldlist,$list); } else { $list[$i] = $filename; } }