This function returns an error. I can't figure out why, but I get this OVER AND OVER AND OVER:
Warning: 1 is not a valid Directory resource in /home/firsttube.com/public_html/code.php on line 52
Warning: 1 is not a valid Directory resource in /home/firsttube.com/public_html/code.php on line 58
I sense this is a very simple piece I'm overlooking, probably with defining the array as empty, but it's also the first time I've written an array that's being dynamically populated (I've tried array_push() but couldn't get that to work either. Help is VERY MUCH appreciated if anyone gets a second!
-Adam
sethadam1@hotmail.com
<?php
$codearray = array ();
$handle=opendir('./code/');
echo "Available Scripts:<p>";
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php") {
//add each file to an array so I can sort
// foreach ( $file as $codefile ) {
$codearray[] = $codefile;
}
closedir($handle);
}
//sort results of new array
sort($codearray);
//one last foreach loop, this time to display results of new array
foreach ( $codearray as $showcode ) {
echo "<a href=display.php?file=$showcode><font color=\"black\">";
$filename = (str_replace("_"," ",$showcode));
$filename = (str_replace(".","(",$showcode));
echo $filename .")</font></a><br>\n";
}
?>