Help plz!
Posted: Sat Dec 03, 2011 1:30 am
I been trying for hours to make this code work but everytime I use a ">" inside the code it stops runing.
When I run the code this is what i get in the browser instead of the files in the directory:
".$directory."
"; // open directory and walk through the filenames while ($file = readdir($handler)) { // if file isn't this directory or its parent, add it to the results if ($file != "." && $file != "..") { echo "hola"; } } // tidy up: close the handler closedir($handler); // done! return $results; } getDirectoryList('/images/display'); ?>
any idea what is wrong?
Code: Select all
<?php
function getDirectoryList ($directory)
{
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// open directory and walk through the filenames
while ($file = readdir($handler)) {
// if file isn't this directory or its parent, add it to the results
if ($file != "." && $file != "..") {
echo "<p>".$filename."</p>";
}
}
// tidy up: close the handler
closedir($handler);
}
getDirectoryList('/images/display');
?>".$directory."
"; // open directory and walk through the filenames while ($file = readdir($handler)) { // if file isn't this directory or its parent, add it to the results if ($file != "." && $file != "..") { echo "hola"; } } // tidy up: close the handler closedir($handler); // done! return $results; } getDirectoryList('/images/display'); ?>
any idea what is wrong?