1.11M Members

Pass variable to url in php

 
0
 

Is this possible to pass the php variable to the url?

my code is:

<?php

	$array1 = array("iphone", "ipad","iMac");

	for($test = 0; $test <= 2; $test++)
{
	echo '<a href="https://www.google.com?$array1[$test]">Click me</a><br />';
}

	
?>

How do i do that when i click on the link it will show the search results???

 
0
 

yes

<?php
 
	$array1 = array("iphone", "ipad","iMac");
 
	for($test = 0; $test <= 2; $test++)
{
	echo "<a href='https://www.google.com?{$array1[$test]}'>Click me</a><br />";
}
 
 
?>

you can also use foreach()

$array1 = array("iphone", "ipad","iMac");
foreach($array1 as $value){
echo "<a href='https://www.google.com?{$value}'>Click me</a><br />";
}
 
0
 

Now what is the output of the above code?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: