Well, this thing is confusing me lot. What I need to do is just extracting data from an array and want to put a clickable link with variable. Like this:
all I end up is this:
I want a comma if there is a second fruit out there. But if I put this
it just put the , (comma) after all fruit.
Can anyone please tell me how to make it right?
PHP Code:
Array
(
[a] => apple
[b] => banana
[c] => orange
)
to <a href="?data=orange">orange</a>
PHP Code:
for ($i = 0; $i < count($fruit); ++$i) { print "<a href='?data=".$fruit[$i]."'>".$fruit[$i]."</a>"; }
PHP Code:
foreach ($fruit as $key => $val) {
print "<a href='?data=$val'>$val</a>, ";
}
Can anyone please tell me how to make it right?
Comment