[PHP] I am stumped
- Date: Sat, 28 Apr 2018 21:16:40 -0700
- From: Jeffry Killen <jekillen@xxxxxxxxxxx>
- Subject: [PHP] I am stumped
I have the following code snips from isolated development project:
I have been doing lots of coding similar to this and don't ever remember encountering
this type of problem. I have a working version based on this elsewhere, as well. I saved
this message as a draft while I looked over the working code and accept for variable name
differences and differences in foreach looping construct: file or dir is tested in the looping
construct and not in core gerDirListSingle code.
This is supposed to scan a directory and produce an associative array where the index is the
file listing and the value is either directory or file.
In the loop, $_itr is set to 1 instead of 0 to try and solve the eventual output question, but doesn't
do it in tests.
private function getDirListSingle($_dir)
$_DR = ;
if(($_DR = scandir($_dir)) === false)
self::$_readError[count(self::$_readError)] = $_dir." not scanned";
for($_itr = 1; $_itr < count($_DR); $_itr++)
self::$_dirsToRead[$_DR[$_itr]] = 'directory';
self::$_dirsToRead[$_DR[$_itr]] = 'file';
next is code to produce a string representation of the array:
($_list['dirs'] is a copy of self::$_dirsToRead)
foreach($_list['dirs'] as $_ind=>$_val)
$_outList[count($_outList)] = $_val.": ".$_ind;
$_out = implode($_outList, "\n");
The following is the result:
testBed is the directory being read for this
Why is testBed/test_1 included and the value is 1
instead of 'directory'. At the bottom of the list is test_1 listed as a file.
Perhaps I have gone blind and can't see a mistake I should be seeing.
// $_out printed out:
Thanks for time and attention;
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php