I’m trying to figure out a way to detect groups of files. For instance:
If a given directory has the following files:
- Birthday001.jpg
- Birthday002.jpg
- Birthday003.jpg
- Picknic1.jpg
- Picknic2.jpg
- Afternoon.jpg.
I would like to condense the listing to something like
- Birthday ( 3 pictures )
- Picknic ( 2 pictures )
- Afternoon ( 1 picture )
How should I go about detecting the groups?
Here’s one way you can solve this, which is more efficient than a brute force method.
preg_replace('/\d//g', $key)).You will have something like
$arr1 = [Birthday001 => Birthday, Birthday002 => Birthday ...]$arr2 = [Birthday => 2, ...]