too tough for me (Verify this number)

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Jul 07, 2003 2:29 pm

Wed Jul 09, 2003 9:10 pm

BW1234561 ---> this number is mathematically correct

i need a script to verify this string of letters and numbers

step 1: this must start with an "a" or a "b" as in the example above (the second letter can be anything)

step 2: Add the 1st, 3rd, and 5th numbers (example = 9)

step 3: Add the 2nd, 4th, and 6th numbers (example = 12)

step 4: Add the results (example = 9 + 12 = 21)

step 5: The 7th number (in the example) is the last digit of the sum of step 4 (the answer is "1" as in "21")

leaving you a result of ---BW1234561

please help (if there is any confusion please let me know)

New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Thu Jul 10, 2003 3:22 am

Use the substr function.

This is how you can check the first letter is A or B

Code: Select all

if ($num{0} == "A" || $num{0} == "B")

Where $num = BW1234561

Post Reply