- glob: documentation ( source)
- str_replace: documentation ( source)
<?php
$type = 'c';
$imagesDir = array('a' => 'a', 'b' => 'b');
$images = glob($imagesDir . $type . '*[TYPE].{jpg,jpeg,png,gif}', GLOB_BRACE);
foreach($images as $image): ?>
<li><a href="<?php echo str_replace('[TYPE]', 'F', $image); ?>"><img src="<?php echo str_replace('[TYPE]', 'T', $image); ?></a>" alt="" /></li>
<?php endforeach; ?>