$value) { if (is_array($value) && count($value) > 0) { $total += count($value); } } function dirToArray($dir) { $ignore = array('.', '..', '_site', 'assets', 'states', 'book', 'filters'); $result = array(); $root = scandir($dir); $dirs = array_diff($root, $ignore); foreach ($dirs as $key => $value) { if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) { $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); } else { if (substr($value, -3) == '.js') { $result[] = $value; } } } return $result; } function printJSLinks($section) { global $files; $output = ""; if ($section) { $tempFiles = $files[$section]; } else { $tempFiles = $files; } foreach ($tempFiles as $key => $value) { if (is_array($value)) { $output .= ""; $output .= printJSLinks($key); $output .= ""; } else { $value2 = substr($value, 0, -3); $file = urlencode($value); $output .= ""; } } return $output; } ?> phaser

Debug