Jump to content

Help with http_build_query


Lassie

Recommended Posts

I need to append some query strings to url's and am trying to use http_build_query.

I have the following  types of url to build where there are varaibles to append

 

 
I have tried the last one first with the following code but I get an error unknown location form the response.
Is this the right way to build query strings? 
 
 
$post_code=$_GET['post_code'];
$key="1234k";//not a real key
$outcode= "outcode";

$fields = array('area'=>$post_code,
'output_type=>$outcode,
'api_key=>$key);
$url = "http://api.zoopla.co.uk/api/v1/zed_index?" . http_build_query($fields, '', "&");
 
Link to comment
https://forums.phpfreaks.com/topic/295046-help-with-http_build_query/
Share on other sites

URL encoding in PHP.

 

And yes, your example is almost correct:

echo "<a target='_blank' href='".$url."'>This Is Example Text</a>";

Note the single quotes around the attribute values and the closing '>' on the opening tag, plus closing quotation marks on the string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.