Page 1 of 1
Casing Variables?
Posted: Mon Oct 14, 2002 6:33 am
by Rob_Beard
Hey,
I'd like to know how i can case variables, eg:
VARIABLE to variable
but using $var1 to stand for VARIABLE
Thanks,
Rob
Posted: Mon Oct 14, 2002 6:39 am
by twigletmac
Are you trying to change the case of a variable's name? If so, why do you need to do this? If not, I'm not sure what you are asking. Either way, a bit more information would probably make it easier to offer you good help.
Mac
Posted: Mon Oct 14, 2002 6:54 am
by Rob_Beard
sorry, didnt make that clear,
What i'm trying to do it change the case of the data held within the variable.
so, re-trying my example
$Variable = "DATA"
I want $Variable to be "data"
any clearer?
Posted: Mon Oct 14, 2002 7:03 am
by twigletmac
Lots clearer,
Code: Select all
$variable = 'DATA';
$variable = strtolower($variable);
echo $variable; // returns 'data'
There's a bunch of case changing functions:
strtoupper(),
strtolower(),
ucwords(), and
ucfirst().
Mac
Posted: Mon Oct 14, 2002 7:09 am
by Rob_Beard
Thankyou!
