Page 1 of 1

Triple echo ???

Posted: Mon May 16, 2005 11:58 pm
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 !

Posted: Tue May 17, 2005 12:04 am
by Burrito
you're inside the loop maybe? try moving it outside of your while loop.