Jump to content

Recommended Posts

while(false!== ($file = readdir($res))) {
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {

if (($info["extension"] == "mp3") || ($info["extension"] == "wav")) {
}else{}
}
}

the problem is that when i put an error msg in the else of the red code part it loops as much as files that are not mp3 or wave type. so how i can stop that from happening? and if i did put it outside it wont read $file variable. or even is it possible to know how to make another variable that can bring results of my search outside the while loop cuz i tried alot of things but didnt work :S

 

Thanks in advance,

Maxwel

Link to comment
https://forums.phpfreaks.com/topic/278319-else-that-wont-loop/
Share on other sites

Muddy_funster is right. You can set the error message in the loop and echo the error message after the loop completes:

while(false!== ($file = readdir($res))) {
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {

if (($info["extension"] == "mp3") || ($info["extension"] == "wav")) {
}elseif(!isset($errorMsg)){
  $errorMsg = "Your Error Message";
}
}
}// now we are out of the loop
if (isset($errorMsg)) echo $errorMsg;
Edited by davidannis
Link to comment
https://forums.phpfreaks.com/topic/278319-else-that-wont-loop/#findComment-1431840
Share on other sites

@davidannis & Muddy_funster ,

Thanks alot that was helpful

 

 

guys been since morning trying to get a way to grab value of a variable from a remote server, tried require, include, fopen, file_get_contents

 

and still cant make it any idea?

Edited by maxwel
Link to comment
https://forums.phpfreaks.com/topic/278319-else-that-wont-loop/#findComment-1431861
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.