Change for loop to foreach

Tested and it works, but has sense to check unique values as categories_id is a autoincrement primary key where is not possible to put duplicate values?