I run a ecommerce site, and I have tons of product images.
The naming rules are simple: productid-picnumber
.
But sometimes theres gaps betweeen the picnumbers.
Example for the pictures for product id 4519:
4519-0.jpg
4519-3.jpg
4519-4.jpg
4519-5.jpg
4519-8.jpg
I'm trying to write an algorithm to rename the pictures. The pictures from this product should be renamed like this:
4519-0.jpg
4519-1.jpg
4519-2.jpg
4519-3.jpg
4519-4.jpg
In order. 0 must always be 0, as it's the main product image. -0 is always there.
Let's say $ids
is an array containing all my product ids.
Is looping through the product ids and using file_exists()
the best way?