Reputation: 5
I'm a bit of a PHP newbie, and I'm trying to do what I believe is quite a complicated operation on a website. So I need your help :)
What I want to do is request a specific page for each client, the only URL variables involved are at the end, as normal.
Basically my variables have been set previously in the script, what I want to say is;
The URL is http://site.com/index.php?image=$clientnumber
Somehow.
if you guys could give me some insight on how to do this, that would be great!
Upvotes: 0
Views: 69
Reputation: 19879
$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data) . "\n";
Results in:
foo=bar&baz=boom&cow=milk&php=hypertext+processor
For your needs:
$data = array('image'=> $clientnumber);
echo 'index.php?' . $data;
Will give you:
index.php?image=878787283
Upvotes: 0
Reputation: 741
$new_url = "http://site.com/index.php?image=$clientnumber";
or
$new_url = 'http://site.com/index.php?image=' . $clientnumber;
Upvotes: 1
Reputation: 21856
You can use the sprintf function to do this:
$url = sprintf('http://site.com/index.php?image=%s', $clientnumber);
Upvotes: 1