I could use some assistance in trying to streamline this jumble of code into maybe a function, or at least slimming this down some.

with this code I am counting the amount of images in a folder (4 folders actually) and then getting that result, and supposedly adding one to it, so therefor when my other code puts an image into that folder it'll be given the new count (so if theres 2 in there, then putting a new fall picture in there would make it fall3, etc)

// this counts the season folders
while ($dircount=readdir($falldn))
closedir ($falldn);


while ($dircount=readdir($winterdn))
closedir ($winterdn);


while ($dircount=readdir($summerdn))
closedir ($summerdn);


while ($dircount=readdir($springdn))
closedir ($springdn);

// end folder count
8 Years
Discussion Span
Last Post by atrophiedsoul

hmm, got a undefined function

Fatal error: Call to undefined function: scandir() in

im betting the $dir which isnt assigned to anything


No, that means you're using PHP4 which is quite unfortunate.

if (!function_exists('scandir')) {
  function scandir($path, $sort = 0)
    if (!$dir = opendir($path)) {
      return array();
    $files = array();
    while (false !== ($file = readdir($dir))) {
      if ($file != '.' && $file != '..') {
        $files[] = $file;
    return $files;

yeh, i keep telling my boss we need to host all this stuff ourselves, and keep our own php and everything updated, but what can ya do, hes stubborn and likes godaddy

i'll test this new function out, and if it works i'll give you a $_COOKIE... geek humor is fun

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.