Casing Variables?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rob_Beard
Forum Newbie
Posts: 23
Joined: Sat Oct 12, 2002 11:58 am

Casing Variables?

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Rob_Beard
Forum Newbie
Posts: 23
Joined: Sat Oct 12, 2002 11:58 am

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Rob_Beard
Forum Newbie
Posts: 23
Joined: Sat Oct 12, 2002 11:58 am

Post by Rob_Beard »

Thankyou! :D
Post Reply