Re: Variable question

From: Date: Sat, 01 Oct 2011 19:00:24 +0000
Subject: Re: Variable question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-315104@lists.php.net to get a copy of this message
On Sat, Oct 1, 2011 at 10:59 AM, Ron Piggott <ron.php@actsministries.org>wrote: > If $correct_answer has a value of 3 what is the correct syntax needed to > use echo to display the value of $trivia_answer_3? You can use variable variables [1] to access the variable by building its name in a string: $name = 'trivia_answer_' . $correct_answer; echo $$name; Peace, David [1] http://php.net/manual/en/language.variables.variable.php

« previous php.general (#315104) next »