Jump to content

Giving me a list of C's and more then the amount I Gave it.


Adrienk

Recommended Posts

So I wrote this piece of code that for the most part works. The problem is two things. One if I print out say $dir[$i] I get 7 directories back. if I try and store that in an array to later be access by some other function I get up to 24+ C's instead of C:/Path...

 

		public function aisis_get_dir_array($dir){

		if(!is_array($dir)){
			aisis_get_dir($dir);
			return;
		}

		$count = count($dir);
		for($i = 0; $i<$count; $i++){
			if(!is_dir($dir[$i])){
				_e('Specified dir' . $dir[$i] . 'is not a directory.');
			}

			$this->directory_list = $dir[$i]; //store these

			$handler = opendir($dir[$i]);
			while($file = readdir($handler)){
				if($file != "." && $file != ".."){
					$this->files[] = $file;
				}
			}

		}

		return $this->files;
	}

 

 

right under the line: $this->directory_list = $dir[$i]; //store these if You put in echo $dir[$i] you get back directories.

How ever down in this function:

 

	public function load_if_extentsion_is_php($dir, $array = false){
		$list = array();
		$list_dir = array();

		if($array == true){
			$list = $this->aisis_get_dir_array($dir);
			$list_dir = $this->directory_list;
		}
		else{
			$list = $this->aisis_get_dir($dir);
		}

		$count = count($list);
		for($i = 0; $i<$count; $i++){
			if($array == true){
				$countdir = count($this->directory_list);
				for($j = 0; $j<$countdir; $j++){
					echo $list_dir[$j];
					//echo $list_dir[$j];
					//echo $list[$i];
				}
			}
			//if(substr(strrchr($list[$i],'.'),1)=="php"){
				//echo $list[$i];
				//require_once($dir . $list[$i]);
			//}
		}

	}

 

echoing out: echo $list_dir[$j]; gets you up to 24+ C's instead of the directories that are stored.

 

You can view the whole class at  Paste bin - there is an expiry: 12 hours.

 

Essentially you call load_if_extentsion_is_php($dir, $array = false) pass it an array of directories and set the array part to true.

 

To Summarize:

 

If you pass in an array of directories you should get back:

 

a echoed list of directories

a echoed list of php files belonging in those directories.

 

Currently you get the later and a series of C's for  the first.

 

Why?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.