Jump to content

Code breaks loop too soon


muckv

Recommended Posts

The moment the code returns the first files[$i] the code continues without finishing the rest

 

I want all the files returned (not in the form of an array), why does the loop break?

 

function get_images_in_subdir($path){
	$files = scandir($path);
	for($i = 0;$i < sizeof($files);$i++) {
		$ext  = substr($files[$i], strrpos($files[$i], '.') + 1);

		if(check_extensie($ext)){
			return $files[$i];

		}

	}

}

Link to comment
https://forums.phpfreaks.com/topic/130287-code-breaks-loop-too-soon/
Share on other sites

The moment the code returns the first files[$i] the code continues without finishing the rest

it doesn't continue!

 

I want all the files returned (not in the form of an array),

How would you like them ?

 

why does the loop break?

It doesn't the function returns when check_extensie($ext) is true.. ( as scripted to do so)

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.