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

Recommended Answers

All 2 Replies

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 />";
}

Now what is the output of the above code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.