> -----Original Message-----
> From: Ron Piggott [mailto:[email protected]]
> Sent: 01 October 2011 18:59
> To: [email protected]
> 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.
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS, LS1 3HE, United Kingdom
E: [email protected] T: +44 113 812 4730
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm