Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A solution would be to use <a href="http://fr.php.net/manual/en/function.opendir.php" rel="nofollow noreferrer"><code>opendir</code></a> + <a href="http://php.net/readdir" rel="nofollow noreferrer"><code>readdir</code></a> + <a href="http://fr.php.net/manual/en/function.closedir.php" rel="nofollow noreferrer"><code>closedir</code></a> <em>(quoting an example from the first page)</em> :</p> <pre><code>$imagesdir = $CFG-&gt;dataroot.'/1/themeimages/'; if ($handle = opendir($imagesdir)) { while (false !== ($file = readdir($handle))) { if ($file != "." &amp;&amp; $file != "..") { echo "$file\n"; } } closedir($handle); } </code></pre> <p><br> Another solution would be to use <a href="http://fr2.php.net/manual/en/directoryiterator.construct.php" rel="nofollow noreferrer">the <code>[DirectoryIterator</code> class</a> ; quoting the example from]<a href="http://fr2.php.net/manual/en/directoryiterator.construct.php" rel="nofollow noreferrer">4</a> the <code>__construct</code> page :</p> <pre><code>$imagesdir = $CFG-&gt;dataroot.'/1/themeimages/'; $dir = new DirectoryIterator($imagesdir); foreach ($dir as $fileinfo) { if (!$fileinfo-&gt;isDot()) { var_dump($fileinfo-&gt;getFilename()); } } </code></pre> <p><br> Of course, in each case, instead of just echoing or dumping the name of the file, you'd have to put it into an array.</p> <p>This would mean initializing the array before the loop :</p> <pre><code>$list_files = array(); </code></pre> <p>And, inside the loop, use something like one of those two lines, depending on which solution you choose :</p> <pre><code>$list_files[] = $file; $list_files[] = $fileinfo-&gt;getFilename(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload