I don't understand why you're doing it this way if they are copies of the same image in different directories. Since they're DIFFERENT, the filename can be the same in both and you don't need to mess with that.
$image = 'some-image.png';
unlink('/path/to/regular/images/' . $image);
unlink('/path/to/cached/images/' . $image);
But to answer your question, can't you just use image functions to get the width/height of the image before you delete it?
PHP Code:
foreach ($path_post as $path) {
$file_name = FCPATH . '/image/' . $path;
//check to make sure image exists
if (file_exists($file_name))
{
//get height/width of image
list($height, $width) = getimagesize($file_name);
//build the cached image file name
$extension = pathinfo($path, PATHINFO_EXTENSION);
$cached_image = FCPATH . 'image/cache/' . utf8_substr($path, 0, utf8_strrpos($path, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
//delete cached image
unlink($cached_image);
//delete regular image
unlink($file_name);
}
}