View Full Version : Dynamically setting Variables?

08-15-2007, 05:38 AM
I'm trying to add some text to a url based upon if it's post variable exists.

Like, if they goto the events page, it will add the highlight code to that link in the menu.

$["$selected"]//My bad attempt

How do I dynamically choose which variable gets "class=\"selected\"" set to it? The variables are $featured, $events, and $past.

if (!isset($_GET["page"])){
$selected = $_GET["page"];
$["$selected"] = "class=\"selected\""; //The code that doesn't work.

echo "<a href=\"index.php?page=featured\" $featured>Featured Events</a></li><li>
<a href=\"index.php?page=events\" $events>All Events</a></li><li class=\"last\">
<a href=\"index.php?page=past\" $past>Past Events</a></li>

08-15-2007, 06:11 AM
its just

$$selected = "class=\"selected\"";

if that doesnt work you cal always try:
${$selected} = "class=\"selected\"";

08-15-2007, 06:12 AM
Ahh, knew it was something like that... Thanks!