No no no... the modulus operator returns the remainder of the operation:
$a % $b Modulus Remainder of $a divided by $b.
So if you have:
$a = 7439;
$b = 500;
$rem = $a%$b;
echo $rem;
$rem will print out: 439
That, is less than 500, so we can round it to 0:
$rem = substr($rem, 0, 1); // Trim it to just the first number, it's all we need
$round = ($rem<5)?'000':'500';
Then, since we've know the prefix, and we've got our suffix (000, or 500), we can create the folder name:
$folder = 'a'.$round;
Hmm... seems their number starts at 1000, and goes through 30000. So we create a loop, and solve that.
for($i=1; $i<30; $i++)
{
$round = ($rem<5)?'000':'500';
$folders[] = 'a'.$i.$round;
}
So we've got folders in an array to use....
My code wasn't meant to work (at least the rounding). What does work is the regex which gets all images from the page. Most posted code is to be a platform to base your code on.