Jump to content

[SOLVED] unreachable statement


muckv

Recommended Posts

function make_thumb_dir($path){

$resource_path = opendir($path) or die('Dir openen gaat niet');

      while (($filename = readdir($resource_path)) != false) {
          if (is_dir($filename) && $filename =! '.'&& $filename =! '..') {
          	$img =	get_images_in_dir($filename);
          	
           }
       }

     closedir($resource_path);	


}

 

I never get through to $img = get_images_in_dir($filename);

 

He checks the $filenames in the if but never executes $img = get_images_in_dir($filename);

 

and the $filename is a directory?

 

Could you guys help me out?

Link to comment
Share on other sites

Well yeah, it works for me too, but he does'nt execute the next line.

 

So it goe like this

 

$filename = string '.' so do'nt go into the if

NEXT

$filename = string '..' so do'nt go into the if

NEXT

 

$filename = string 'bram' since bram is a directory he should proceed with the code in the if statement right? well it doesn't instead it goes to the next $filename

NEXT

 

$filename = string 'jan' same as above

NEXT

 

$filename = string 'suzy' same as above, end of function

NEXT

Link to comment
Share on other sites

function get_images_in_dir($validpath)
{
   

    $files = scandir($validpath);

    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
Share on other sites

forget all the code before and look at this

function check_for_dir($path){

$resource_path = opendir($path) or die('Dir openen gaat niet');

      while (($filename = readdir($resource_path)) != false) {
          if (is_dir($filename)) {
          		echo $filename;
          
           }
       }

     closedir($resource_path);	


}

 

tough there are 3 dirs in the given path

the output is ...

he evaluates the 3 dirs as NO dirs in is_dir()

 

 

Link to comment
Share on other sites

I had to prepend the working dir.

 

function check_for_dir($path){

$resource_path = opendir($path) or die('Dir openen gaat niet');

      while (($filename = readdir($resource_path)) != false) {
          if (is_dir('./main'$filename)) {
                echo $filename;
         
           }
       }

     closedir($resource_path);   
   
   
}

Link to comment
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.