title: Advanced PHP Directory With JSON Output
body: <p>I'm currently working on a PHP script, that I can use for my mobile app, to connect to our server and get JSON data as a response of the connection. </p>
  
  <p>I have created a very simple PHP directory which will output JSON as the response: </p>
  
  <pre><code>&lt;?php
  
  // An array of the file names
  $directory = array();
  
  //Open directory
  $dir = opendir("./");
  
  //List files in directory
  while (($file = readdir($dir)) !== false)
  {
      $directory[] = $file;
  }
  closedir($dir);
  
  echo json_encode($directory);
  ?&gt;
  </code></pre>
  
  <p>However, I am looking (if possible) to get more functionality out of this script but as I am relatively new to PHP, I am not entirely sure how I would go about getting the data I would like to use: </p>
  
  <ul>
  <li>file name</li>
  <li>file type</li>
  <li>file size</li>
  <li>date/time modified</li>
  <li>date/time created</li>
  <li>user that created the file</li>
  <li>url to the file</li>
  </ul>
  
  <p>Would it also be possible to somehow identify whether the response was a file or a folder? As <code>..</code> would go to another directory &amp; assign an id to each outputted file?</p>