redarrow Posted February 21, 2007 Share Posted February 21, 2007 the return off the loop gets double dots now i wont to start the file while loop to start from 2 but this didnt work why please chers. while(false !== ($file[2] = readdir($images))) { Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/ Share on other sites More sharing options...
ted_chou12 Posted February 21, 2007 Share Posted February 21, 2007 try this: while(readdir($images) == true) { and while(readdir($images) === true) { Ted Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190394 Share on other sites More sharing options...
Jenk Posted February 21, 2007 Share Posted February 21, 2007 <?php while (($file = readdir($dirhandle)) !== false) { if (!in_array($file, array('.', '..')) { // do stuff. } } ?> Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190400 Share on other sites More sharing options...
redarrow Posted February 21, 2007 Author Share Posted February 21, 2007 wont work why dont no! <?php ob_start(); $images=opendir("upload_new/test/"); while(readdir($images)== TRUE) { echo "Filename: $file\n"; $filename = "upload_new/test/$file"; header('Content-type: image/png'); header('Content-length: '.filesize($filename)); readfile($filename); } ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190411 Share on other sites More sharing options...
ted_chou12 Posted February 21, 2007 Share Posted February 21, 2007 Maybe you should try something like this: <?php // Note that !== did not exist until 4.0.0-RC2 if ($handle = opendir('/path/to/files')) { echo "Directory handle: $handle\n"; echo "Files:\n"; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { echo "$file\n"; } /* This is the WRONG way to loop over the directory. */ while ($file = readdir($handle)) { echo "$file\n"; } closedir($handle); } ?> I got this straight off the manual, try to see if the readdir part works fine, because I dont see any problems in your code... Ted Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190421 Share on other sites More sharing options...
redarrow Posted February 21, 2007 Author Share Posted February 21, 2007 the idear is to loop throw the directory and show all throw the while loop. does not work. <?php header("Content-type: image/png"); $images=opendir("upload_new/test/"); while(FALSE!==($file = readdir($images))){ $im = imagecreatefrompng($images.$file); $orange = imagecolorallocate($im, 220, 210, 60); $px = (imagesx($im) - 7.5 * strlen($string)) / 2; imagestring($im, 3, $px, 9, $string, $orange); imagepng($im); imagedestroy($im); closedir($images); } ?> Link to comment https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.