See Variable number of foreach loops
In reply to Re: nested loops by hdb in thread nested loops by baxy77bax