You can just use http_build_query here. It's much cleaner.