RE: [PHP] Variable question
| From: | Ford, Mike | Date: | Mon, 03 Oct 2011 07:52:03 +0000 |
| Subject: | RE: [PHP] Variable question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315115@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Ron Piggott [mailto:ron.php@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.
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: m.ford@leedsmet.ac.uk 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