Page 1 of 1
variable string inside fixed string
Posted: Sat May 01, 2010 11:54 pm
by Richard_in_Az
Code: Select all
<?php
$rel="rel=";
for ($i=1; $i<=2; $i++){
echo "<li><a href='#' rel='country1' class='selected'>$pic[$i]</a></li>";
}
?>
Problem: How do I make it so that during the loop, $i is added to "country"?
So that the html output will show "country1", "country2", "country3" etc etc.
Re: variable string inside fixed string
Posted: Sat May 01, 2010 11:56 pm
by requinix
I see you already know how to put variables in strings. So what don't you understand?
Stick the variable right in there just like as you did with $pic.
Re: variable string inside fixed string
Posted: Sun May 02, 2010 2:23 am
by Richard_in_Az
As they say in Missouri, show me. I have tried various combinations and nothing works for me.
Re: variable string inside fixed string
Posted: Sun May 02, 2010 2:44 am
by Richard_in_Az
Code: Select all
<?php
$link="<a href='#' rel='country'";
for ($i=2; $i<=2; $i++){
$link.=$i.">";
echo "<li>$link $pic[$i]</a></li>";
}
?>
Ok so I worked out this. Now the problem is, the "country" is supposed to be passed on to the next part of the code as a unique id.
But that isn't happening. As in
Code: Select all
<div id="country1" class="tabcontent">
Re: variable string inside fixed string solved
Posted: Sun May 02, 2010 3:38 am
by Richard_in_Az
Code: Select all
<?php
for ($i=2; $i<=2; $i++){
echo "<li><a href='#' rel = country$i>";
echo "$pic[$i]</a></li>";
}
?>