I had similar problems with my 3G phone wifi after upgrading to 3.0. 3.1 did not improve things, so I took it to the Apple Store, who naturally knew nothing of this problem, and was given a new iphone.
That was a month ago. Earlier this week, BAM!, this new phone stopping connecting to wifi and nothing I have done gets it going again.
Oddly, the two problems occurred very differently. The first phone could not detect wifi networks at all, started out intermittent and slowly got so that I could NEVER get it to see networks. This second phone sees the network, but forgets passwords, fails to connects and doesn't see any of the wifi's network settings. And it occurred very suddenly: it was working beautifully one day, then not at all the next.
I don't know what the chances are of Apple replacing my phone a second time, but I wonder if the replacement was a refurbished phone with wifi issues in a prior life.
(And, yes, I did everything possible to test out the phone and my wifi network. I've reset/restored/reeverythinged my phone. Other iphones and laptops have no problems with my wifi and my phone can't connect to ANY wifi)