I want to rewrite it. What I want it to do (and how it used to work):
- Look at the files in a given directory and gather data about them
- the data will be used to create an alphanumeric list of those objects
- use that alphanumeric data result to display info about those objects in such a way as to view the filenames as HTML output, and perhaps click the file itself to view it in the browser if it is HTML, txt, .conf, etc.
I already have the HTML / .js part setup in a generic way to suit me for now. I need a component that will iterate over the filesystem. I was trying to put the info as described above into a multidimensional array so i could have $array[$sortCharAsKey][$objectAsStringName]
Let a directory contain the following objects:
A_file.txt
B_file.ini
B2_file.jpg
directory
disk_db.sql
sname.html
sname.js
// $anKey will be assigned value of the first char of the filename, in order to match the array key / values for the $alphaNum[$forEachKey] array in a foreach loop using something based on
while (($thisObject = readdir($dh)) !== false) { ...
$alaphaNum[$anKey] // where $anKey in this instance might be D to match the objs found:
// "directory", and "disk_db.sql". ,
$alphaNum is an array whose values were created like so:
(sorry for semantic errors... i'm trying to just provide the example without pasting a bunch of code)
$alphaNumString = '123abcd_etc';
$alphaNum = str_split($alphaNumString);
$alphaNum = array_flip($alphaNum);
it's not actually the same variable assignment at this point, but for illustration of concept as to why i'm trying to assign values to an array like that. so...
echo $alaphaNum[6][0] ."\n". $alphaNum[6][1]; // assuming $alphaNum[6] corresponds to D
// would print :
directory
disk_db.sql
I used to be able to accomplish it by assigning the value to and creating the multidimensional array using the empty brackets, like so:
$alphaNum[$anKey][] = $objectString
// where $objectString is "<html stuff>some_file_.txt</html stuff>"
but newer versions of PHP don't support it, and I don't understand how to do what i'm trying to do otherwise. So i'm ready to look at someone else's code at this point. 🙂