Foreach is the king of processing arrays. Try this on for size...
[php]
$filename=array(
'arch_001.jpg', 'arch_002.jpg', 'arc h_003.jpg',
'logo_001.jpg', 'logo_002.jpg', 'iden_001.jpg',
'clad_001.jpg', 'clad_002.jpg', 'firt_001.jpg',
'firt_002.jpg'
);
foreach ($filename as $key => $value) {
$filecategory=substr($value, 0, 4); // Get category.
$filecat[$filecategory][] = $value;
}
[/php]
You dont need this counter anymore.
Code:
$countup=10;
using empty [] pushes your value onto the end of the array. If you want to preserve the original index use $filecat[$filecategory][$key] = $value instead.
Enjoy
Edit: Eeee the orange in the php code comments looks nasty, moved them out of the code section. Brad....