I have the following code, which works on one server running PHP 4.3.3, but doesn't work on another, running 4.3.2. I can't seem to figure out what the problem with the variable is. The "foreach" loop around line 13 is to count the number of items in the array ($total).
Error on 4.3.2 is triggered as an undefined variable "total" on line 13:
$total = $total + 1;
Full code below...
<?php
$the_array = Array();
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php" && $file != ".htaccess") { /* as descripted below: these "files" will not be added to the array */
$the_array[] = $file;
}
}
closedir($handle);
foreach($the_array as $key => $value){
$total = $total + 1;
}
$total = $total - 1;
$next = $element + 1;
if($next > $total){$next = 0;}
$prev = $element - 1;
if($prev < 0){$prev = $total;}
?>