muckv Posted October 27, 2008 Share Posted October 27, 2008 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]; } } } Quote Link to comment https://forums.phpfreaks.com/topic/130287-code-breaks-loop-too-soon/ Share on other sites More sharing options...
MadTechie Posted October 27, 2008 Share Posted October 27, 2008 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) Quote Link to comment https://forums.phpfreaks.com/topic/130287-code-breaks-loop-too-soon/#findComment-675797 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.