Okay I have a directory named thumbs, and in it is are thumbnails for my products. I have named them like so (using product id 9 as example) 9_1.jpg, 9_2.jpg, 9_3.jpg, and so on. Now I need to find out how to count how many thumbnails are for the product are in this directory. I tried using this code:
$id = $GET['id'];
$count = 0;
$this_regexp = "/\b$id\b/i";
$this_dir = dir('previews/thumbs/');
if ($this_regexp != null) {
while ($file = $this_dir->read()) {
if (preg_match($this_regexp, $file)) {
$count++;
}
}
}
But the problem is it matches and counts all images for say item 19_1.jpg, 29_1.jpg, and so on because 9_ is matched. Please help, I know it is in my $this_regexp statement but can't figure it out.