Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by pauldreed

  1. Thanks Phsycho. Yes that makes complete sense, and including the paths in an array has already solved another problem that was looming! Many Thanks Paul
  2. Thanks Psycho, but I've finally got my head around it! <?php $schema = array(); $path = "/home/pi/path/path/*"; $path1 = "/home/pi/path/path1/*"; $dir1 = glob($path); $dir2 = glob($path1); $dir = (array_merge($dir1,$dir2)); for ($i=2; $i<count($dir); $i++) { if (filetype($dir[$i])=='dir') { $app = basename($dir[$i]); if (is_file($dir[$i]."/".$app."_schema.php")) { require ($dir[$i]."/".$app."_schema.php"); } } } print_r($schema);
  3. Yes, it's currently stable & working fine with one directory. Directory1 = the modules which are installed by the app by default, and come with a standard installation via git Directory2 = a new 'user' directory, where users can add additional modules to increase functionality. I really don't want users adding 'user' modules to 'Directory1'. Thanks for the tip about is_dir() & is_link(). I'll update that. Paul
  4. The actual code is https://github.com/emoncms/emoncms/blob/master/core.php#L115-L130 $schema is used to hold a number of arrays which hold data about modules contained in the /Modules directory. That data is used to load the modules. Paul
  5. I've tried to use scandir & array_merge, but just can't get it to work. I've got to admit I'm an absolute beginner with php and it seems a very steep learning curve! Has anyone got an example of how this should be written please. Paul
  6. The below scans a directory and returns the values as an array using scandir, which works fine. However, I would like it to build the array from 2 directories instead of just one. For example; /home/pi/testDir1 & /home/pi/testDir1 I understand that I need to iterate over both directories, but despite spending hours so far, I just can't get it to work! Any help would be appreciated. Paul <?php $path = "/home/pi/testDir1"; $schema = array(); $dir = scandir($path); for ($i=2; $i<count($dir); $i++) { if (filetype(($path."/").$dir[$i])=='dir' || filetype(($path."/").$dir[$i])=='link') { if (is_file(($path."/").$dir[$i]."/".$dir[$i]."_schema.php")) { require ($path."/").$dir[$i]."/".$dir[$i]."_schema.php"; } } } print_r($schema);
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.