Both pulled off this legitimately impressive (if temporary) feat by focusing, before anything else, on housing. The New York Times sums up the rationale behind Phoenix's approach:
According to local and national surveys, it is more expensive to cover the costs of emergency room visits or nights in jail for homeless people than it is to give them homes. A 2009 analysis commissioned by the Los Angeles Homeless Services Authority, which handles the largest population of homeless veterans in the country, found that the monthly cost of housing and supportive services for one person was $605, while the public costs of a person living on the streets were roughly $2,900 a month.
Across the country, the strategy is centered on an approach called Housing First, through which a home is not treated as a reward for good behavior.
The logic is simple and economically compelling. By paying something up front to give people a place to live, a city can save a lot of money on social services.
The political difficulty arises when moralizers object that homeless people should not be "rewarded" with subsidies. In fact, society always pays one way or another. Enacting a comprehensive housing program for homeless veterans, who have already made a donation to the public, so to speak, is more palatable. But if no-questions-asked housing works for homeless veterans, it should work for all homeless people. Let's do it.