Use simple foreach to walk through array and rearrange its contents