Added tools for generating JSON tree with Dewey Decimal System
[mirrors/Programs.git] / bash / dewey_decimal_system / genjson.php
diff --git a/bash/dewey_decimal_system/genjson.php b/bash/dewey_decimal_system/genjson.php
new file mode 100755 (executable)
index 0000000..072f3c4
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/php
+<?php
+//You will need JSON PHP extension for this script...
+
+function recursive_scandir($path,&$dir) {
+       foreach($dir as $key => $value) {
+               $dir[$key] = array_flip(scandir($path.'/'.$key, 0));
+               unset($dir[$key]['.']); unset($dir[$key]['..']);
+               recursive_scandir($path.'/'.$key,$dir[$key]);
+       }
+}
+
+$dds = array_flip(array('dds'));
+recursive_scandir('./', $dds);
+
+//print_r($dds); //you can use this if you don't have JSON ext.
+echo json_encode($dds);
This page took 0.148263 seconds and 4 git commands to generate.