$ar=array("FName"=>"John","Address"=>"Street No 11 ","City"=>"Rain
Town","Country"=>"USA");
echo http_build_query($ar);
The Output of above script is here
FName=John&Address=Street+No+11+&City=Rain+Town&Country=USA
Now this above string is ready to post through any URL. Here is an example.
<a href=anypage.php?FName=John&Address=Street+No+11+&City=Rain+Town
&Country=USA>Send Address</a>
Inside any script development we will be using dynamic data to generate the string and pass it through URL , so here is the complete code. <?Php
$ar=array("FName"=>"John","Address"=>"Street No 11 ","City"=>"Rain
Town","Country"=>"USA");
$str=http_build_query($ar);
echo "<a href=anypage.php?$str>Send Address</a>";
?>
Note that your array can be from a database table and similar way you can generate script to pass each address to any application.
$data = [
'user' => 'john',
'preferences' => ['theme' => 'dark', 'notifications' => 'on']
];
echo http_build_query($data);
// Output: user=john&preferences%5Btheme%5D=dark&preferences%5Bnotifications%5D=on
$data = ['name' => 'John Doe', 'email' => 'john@example.com'];
echo http_build_query($data, '', '&', PHP_QUERY_RFC3986);
// Output: name=John%20Doe&email=john%40example.com
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.