Triple echo ???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sacapuss
Forum Commoner
Posts: 40
Joined: Mon May 16, 2005 9:46 pm
Location: Earth...

Triple echo ???

Post by Sacapuss »

Hi !

The final echo happens thrice. Could you explain me why :?:

Code: Select all

<?php // js_file_array_generate_out_of

function js_file_array_generation_launch_out_of($dir)
{
$dir_handler = opendir($dir);
echo "my_array=[";
js_file_array_generate_out_of($dir, $dir_handler);
}

function js_file_array_generate_out_of($dir, $dir_handler)
{
$object = readdir($dir_handler);
if(filetype("$dir/$object") == "file")
echo "'$dir/$object'";
else
js_file_array_generate_out_of($dir, $dir_handler);

while($object = readdir($dir_handler))
if(filetype("$dir/$object") == "file")
echo "', $dir/$object'";

echo "]";
}

js_file_array_generation_launch_out_of(".");

?>
Thanx for your help !
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you're inside the loop maybe? try moving it outside of your while loop.
Post Reply