Jump to content

Directory Array


JREAM

Recommended Posts

I have this trying to print up a directory array, so it would read like:

 

$encoded[0] = '###file1###';

$decoded[0] = 'file1.php';

$encoded[1] = '###file2###';

$decoded[1] = 'file2.php';

 

or something close to that, doesn't matter -- they just have to match up .. and so on..

 

Can you see what I am doing wrong?

	if ($handle = opendir(BLOCKS_DIR)) {

	$i = 0;

	while (false !== ($file = readdir($handle))) {
	if ($file != "." && $file != "..") {
		$encoded[$i] = '####'.removeExt($file).'###';
		$decoded[$i] = BLOCKS_DIR . removeExt($file) .'.php';
		$i++;

	}
	// print_r($encoded);  // This prints up a nightmare
    }
    closedir($handle);
}

 

Here's some of the the Print_r:

##block-3### [8] => ####block-4### [9] => ####block-5### [10] => ####block-6### [11] => ####block-7### ) Array ( [0] => ####a### [1] => ####as### [2] => ####asd### [3] => ####asdasd### [4] => ####block-1### [5] => ####block-10### [6] => ####block-2### [7] => ####block-3### [8] => ####block-4### [9] => ####block-5### [10] => ####block-6### [11] => ####block-7### [12] => ####block-8### ) Array ( [0] => ####a### [1] => ####as### [2] => ####asd### [3] => ####asdasd### [4] => ###

Link to comment
https://forums.phpfreaks.com/topic/125281-directory-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.