Note that there are some explanatory texts on larger screens.

plurals
  1. POauto display filename in a directory and auto fill it as value
    text
    copied!<p>I want something (final) like this : </p> <pre><code>&lt;?php //named as config.php $fn[0]["long"] = "file name"; $fn[0]["short"] = "file-name.txt"; $fn[1]["long"] = "file name 1"; $fn[1]["short"] = "file-name_1.txt"; ?&gt; </code></pre> <p>What that I want to?:</p> <pre><code>1. $fn[0], $fn[1], etc.., as auto increasing 2. "file-name.txt", "file-name_1.txt", etc.., as file name from a directory, i want it auto insert. 3. "file name", "file name 1", etc.., is auto split from "file-name.txt", "file-name_1.txt", etc.., </code></pre> <p>and config.php above needed in another file e.g.</p> <pre><code>&lt;? //named as form.php include "config.php"; for($tint = 0;isset($text_index[$tint]);$tint++) { if($allok === TRUE &amp;&amp; $tint === $index) echo("&lt;option VALUE=\"" . $text_index[$tint]["short"] . "\" SELECTED&gt;" . $text_index[$tint]["long"] . "&lt;/option&gt;\n"); else echo("&lt;option VALUE=\"" . $text_index[$tint]["short"] . "\"&gt;" . $text_index[$tint]["long"] . "&lt;/option&gt;\n"); } ?&gt; </code></pre> <p>so i try to search and put php code and hope it can handling at all : e.g.</p> <pre><code>&lt;?php $path = "."; $dh = opendir($path); //$i=0; $i= 1; while (($file = readdir($dh)) !== false) { if($file != "." &amp;&amp; $file != "..") { echo "\$fn[$i]['short'] = '$file'; $fn[$i]['long'] = '$file(splited)';&lt;br /&gt;"; // Test $i++; } } closedir($dh); ?&gt; </code></pre> <p>but i'm wrong, the output is not similar to what i want, e.g.</p> <pre><code>$fn[0]['short'] = 'file-name.txt'; ['long'] = 'file-name.txt'; //&lt;--not splitted $fn[1]['short'] = 'file-name_1.txt'; ['long'] = 'file-name_1.txt'; //&lt;--not splitted </code></pre> <p>because i am little known with php so i don't know how to improve code more, there are any good tips of you guys could help me, Please</p>
 

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