0

I've been trying out arrays recently, and this is my coding:

<?php
$data = array('autoguide1'=>'car',
              'baz'=>'boom',
              'scotland'=>'haggis',
              'php'=>'hypertext processor');

echo http_build_query($data); // autoguide1=car&baz=boom&scotland=haggis&php=hypertext+processor
echo http_build_query($data, '', '&amp;'); // foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor

?>

What I want to try and do is make my PHP code run so that I can include a file from another page on my site, e.g.
http://mysitehere-localhost.com/testing.php?yourpage&scotland=haggis

and depending on the URL it will take the array and use the generated query string.

Thanks.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by slyme
0

Do you mean you want to generate a hyper link on the page using the the items in the array? Sort of like this:

echo '<a href="http://mysitehere-localhost.com/testing.php?yourpage' . http_build_query($data) . '">my link</a>';

The 'yourpage' bit of the link is throwing me (what's it for?) a bit so maybe I haven't quite got what you want to do.

Sorry if I have misunderstood, hope this helps ...
Simon.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.