1,105,254 Community Members

Pass variable to url in php

Member Avatar
zeeshanmughal
Newbie Poster
8 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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???

Member Avatar
Biiim
Posting Pro
504 posts since Oct 2011
Reputation Points: 85 [?]
Q&As Helped to Solve: 86 [?]
Skill Endorsements: 9 [?]
 
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 />";
}
Member Avatar
karthik_ppts
Posting Pro
574 posts since Feb 2011
Reputation Points: 81 [?]
Q&As Helped to Solve: 101 [?]
Skill Endorsements: 1 [?]
 
0
 

Now what is the output of the above code?

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