I have a simple image-looping script that changes the `src` of an image.

```
function cycleNext()
{
    ++imgIndex;

    if(imgIndex>imgCount)
    {
        imgIndex = 1;
    }

    setImgSrc(imgIndex);
}

```

However, at present, I'm (shudder) *manually entering* `imgCount` in my script. The alternative is server-side, but I don't know how to fetch this information. I imagine it's pretty simple, though.

How can I use PHP to supply this script with the number of images in the folder?