Go check out the Arrays for beginners tutorial , making this wouldn't be too hard , you just need to check if there is a 0 in the array and remplace the zero by the ID of an item in a for every elements loop ...
I'll make you an example when I get home