Jump to content

Adrienk

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Adrienk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Why thank you. Your help is much appreciated
  2. This, from my understanding - correct me if I am wrong. sais: delete all files except the directory I'm deleting files in. Which is fine. how ever I need to delete a;ll files in said directory EXCEPT for specified files. So essentially: AISISCORE would be empty - EXCEPT for the files I don't want deleted. maybe I missed something in your example? thanks for the help
  3. So I assume no? I have noticed this form moves fast - hence the bump. sorry for rule breaking. kinda need an answer - dont hate me.
  4. So I am having issues. like mental issues over this.... I found a piece of code on the php manual site in relation to recursively deleting directories and modified it to this: function delete_contents_in_folder($path_to_dir){ if(is_file($path_to_dir)){ return @unlink($path_to_dir); } elseif(is_dir($path_to_dir)){ $scan = glob(rtrim($path_to_dir,'/').'/*'); foreach($scan as $index=>$path){ $this->delete_contents_in_folder($path); } if($path_to_dir == AISISCORE){ return; }else{ return @rmdir($path_to_dir); } } } essentially AISISCORE is the directory i want it to IGNORE. so essentially it deletes every file, sub directory and so on in AISISCORE but does not delete the root directory, in the end AISISCORE is left as an empty folder. What's the issue? I want to tell it to delete everything in AISISCORE as it already does BUT ignore specific files when doing so, that's the part I can't figure out how to do. Your help is appreciated.
  5. There is no edit button? Any ways I just realized the link was broken for the pastebin.... So http://pastebin.ca/2139415 Any ways, OP still counts. you'd just have to uncomment out the echo. How ever I have come across an interesting problem...you see here how I am returning this all to an array? (essentially this function returns an array of all the images in said directory) Well if I use that method and walk through the returned array on the front end I get i instead of image1.jpg How ever if I just do an echo on this method I get back image1.jpg instead of image1.jpgimage2.jpg which is insanly odd....Im thinking its my loop. because if I echo out images as you see in the class then I get image1.jpgimage1.jpgimage2.jpg and if I return this function and walk through it I get i also why is there no edit button - or am I blind >.> (edit button for the OP)
  6. So I have a folder with two images. What happens with the code on pastebin is that it goes through checks the directory, checks for files in the folder with the extension.jpg and then prints them out into a image tag. I understand the for loop is probably a no no in php and we should use for each, but I like this way better >_>. Aside from that, this whole this works, it goes through gets the images. Problem? It prints the first image twice and the second once. So: $this->get_images_in_dir[0] results in 2 images (the image printed twice) where as $this->get_images_in_dir[1] results in one. why? It should only print it once. like: $this->get_images_in_dir[0] results in image1.jpg $this->get_images_in_dir[1] results in image2.jpg instead of image1.jpg, image1.jpg, img2.jpg Ideas?
  7. 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?
×
×
  • 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.