tags:

views:

4150

answers:

3

Hi,

I'm looking for the name of the PHP function to build a query string from an array of key value pairs. Please note, I am looking for the built in PHP function to do this, not a homebrew one (thats all a google search seems to return). There is one I just can't remeber it's name or find it on php.net. IIRC it's name isn't that intuitive.

Robin

A: 

I'm not aware of a builtin function, but there is the PECL class http://uk.php.net/manual/en/class.httpquerystring.php

Adam Wright
A: 

Implode will combine an array into a string for you, but to make an SQL query out a kay/value pair you'll have to write your own function.

Click Upvote
Tried that but it won't work. I'm trying to build an http query string which requires both the keys and the values from the array, implode can't do this.
I see, wasn't sure if you meant an SQL query string or a http query string.
Click Upvote
+23  A: 

Your looking for http_build_query().

tj111
Yeah, that's the one.
Wish I'd known about that function a long time ago. Heh.
ceejayoz
I can never remember it either.
Rimian