> -----Original Message-----
> From: Ron Piggott [mailto:ron....@actsministries.org]
> Sent: 01 October 2011 18:59
> To: php-general@lists.php.net
> Subject: [PHP] Variable question
> 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?
> I know this is incorrect, but along the lines of what I am wanting
> to do:
> echo $trivia_answer_$correct_answer;

Just for the record, one more way of doing what you asked for is:

    echo ${"trivia_answer_$correct_answer"};

But I totally agree with all the suggestions to use an array instead.



Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk     T: +44 113 812 4730

To view the terms under which this email is distributed, please go to 

Reply via email to