salewit - 6:12 pm on Apr 21, 2011 (gmt 0)
Well the tip on turning on error reporting was the one that solved the mystery! Here's what happened if you're interested. Basically this script is going through several features of my website menu. It's not only building an index of how many items for each vendor (the code which I had here), but it's also building an index of items that are based in different countries, states, categories and a few other things. Then it builds a menu bar and stores that so that when a visitor visits a page, the menu is cached and doesn't get rebuilt every time with all this work. Well if you noticed, a couple of the vendor ID's that I had trouble with were "ri" and "mp". When I looked at the error reporting later in the script, I saw this: "Notice: Undefined index: RI on line 172".
Well what it turned out to be is the STATE code of Rhode Island is also RI and we have product that comes from Rhode Island thus the 0 was getting written AFTER the 11 from the vendor. The MP was the country code of "Northern Mariana Islands" which of course we had no product from.
So mystery solved! Thank you very much for your help on this. I don't think I would have figured it out if you hadn't mentioned turning the reporting on.