We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,145 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Pass variable to url in php

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???

3
Contributors
2
Replies
6 Minutes
Discussion Span
1 Year Ago
Last Updated
3
Views
zeeshanmughal
Newbie Poster
8 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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 />";
}
Biiim
Posting Pro
504 posts since Oct 2011
Reputation Points: 104
Solved Threads: 83
Skill Endorsements: 7

Now what is the output of the above code?

Karthik_pranas
Posting Pro
571 posts since Feb 2011
Reputation Points: 96
Solved Threads: 101
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0664 seconds using 2.76MB