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

function count_dir($dirname)
  return count(array_slice(scandir($dir), 2));

$seasons = array('spring', 'summer', 'winter', 'fall');
$springcount = $summercount = $fallcount = $wintercount = 0;
foreach ($seasons as $season) {
  $seasoncnt = $season . 'count';
  $$seasoncnt = count_dir("images/" . $season);
// done

Whoops: For Reference Variable Variables, http://php.net/scandir, http://php.net/array_slice

ah hah, i'll test that out and let you know the results

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