The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

convert this to a PHP script?

Ever wonder about those people who say they are giving more than 100%?

We have all been to those meetings where someone wants over 100%.

How about achieving 103%? Here's a little math that might prove helpful.

What makes life 100%?

If

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z is represented

as:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26.

Then,

H A R D W O R K
8 1 18 4 23 15 18 11 = 98%

K N O W L E D G E
11 14 15 23 12 5 4 7 5 = 96%

But,

A T T I T U D E
1 20 20 9 20 21 4 5 = 100%

And,

B U L L S H I T
2 21 12 12 19 8 9 20 = 103%

So, it stands to reason that hardwork and knowledge will get you close, attitude will get you there, but bull**** will put you over the top.

And look how far

A S S K I S S I N G
1 19 19 11 9 19 19 9 14 7 = 118%

will take you.

im still learning PHP, and i took it upon myself to try and convert the above into a PHP script.
so if someone enters the word: PUNCTUALITY
the script outputs: 16 21 14 3 20 21 1 12 9 20 25
(P=16, U=21, N=14 ... etc.)
but im having trouble.

i dont know HOW to make my script ADD up the value of each letter.
know whatta mean?

so when someone enters a word, it shows them the numerical % equvilant.
here is what i have so far:

Ap0s7le beat me to it.
but umm, i think my code is slightly better. in that it doesn't require the user to have spaces in their words for a correct calculation to be achieved. and it's much much shorter code.