Re: build variable names from variables
| From: | Chris Hewitt | Date: | Mon, 14 Apr 2003 15:20:37 +0000 |
| Subject: | Re: build variable names from variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143787@lists.php.net to get a copy of this message | ||
Roger 'Rocky' Vetterberg wrote:
Hi list.
I have a script with snippets of code looking like this:
if ($row->category == RMA) {$num_RMA++;} if ($row->category == firmware) {$num_firmware++;}
if ($row->category == other) {$num_other++;}
..
echo "Category RMA: $num_RMA";
echo "Category firmware: $num_firmware";
echo "Category other: $num_other";
I'd have used a switch statement rather than all those "if"s, but maybe what you are looking for are "variable variables". Its in section II Language Reference, sub-section 7 variables, of the manual.
HTH
Chris