From: "Jamie Saunders" <[EMAIL PROTECTED]>
Subject: [PHP] adding text to a variable name

> Is it possible to add text onto the end of a variable name?
> e.g. to add the word 'code' onto the variable $field so it would be $fieldcode

I think you want to do it in an automatic way for each variable which satisfies a 
prescribed condition, so you may use a for / while statement

for ( ; ; ) {
    GLOBALS[$old_name . "_put_your_own_postfix_here"] = GLOBALS[$old_name];
}

or with variable variables:

for ( ; ; ) {
    $new_name = $old_name .  "_put_your_own_postfix_here";
    $$new_name = $$old_name;
}

but if you know the name of variables exactly, the simplest solution is already 
posted. $var_code = $var;



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to