I returned several iPhone 3g handsets, each time they were replaced (for refurbished) and each time the same thing happened, broken wifi. Turned out the cable on the charger was slightly frayed. It charged properly and transferred data for backups etc, but fried the wifi chips.
Apple had replaced handsets but left me with the original data cable and plug. I was pulling my hair out trying to figure out what was going wrong with the handsets. After ruling out software updates, magnetic fields etc, I bought a new charger/data cable.
Lo and behold - no problems!
If Apple store had given me a complete replacement first time (including cables and charger) it would have saved two subsequent handsets from fried wifi chips.