I think the line: print "$layers[i]<br />"; should be print "$layers[$i]<br />"; ...I hate it when that happen ;) Cheers! Chip