[K12OSN] PHP and variables

Doug Simpson simpsond at leopards.k12.ar.us
Tue Sep 9 12:47:30 UTC 2008


I know how to get data in from a form, but I need to know how to get a string converted from a letter variable to a number variable.

Example:

Say there are two choices and I am using radio buttons to select which choice the viewer wants.

It stores the first choice as "a" and the second choice as "b". This I know how to do.

So I would like to convert the a to 1 and the b to 1 and store them each in another variable of their own. I know how to get them into another variable, also.

Now, I want to add up the number of "a"s and the number of "b"s .

All I really need to know is how to convert a letter to a number in PHP.

if choice=a then choice1num=1   <<<<this part
if choice=b then choice2num=1   <<<<this part
echo choice1num
echo choice2num

Thanks!

Doug Simpson
Technology Specialist
De Queen Public Schools
De Queen, AR
simpsond at leopards.k12.ar.us
"A Dollar Saved is a Dollar Earned"






More information about the K12OSN mailing list