Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

too tough for me (Verify this number)

Codes here !

Moderators: macek, egami, gesf

too tough for me (Verify this number)

Postby icu90ucme » 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)
icu90ucme
New php-forum User
New php-forum User
 
Posts: 23
Joined: Mon Jul 07, 2003 2:29 pm

Postby Joel » Thu Jul 10, 2003 3:22 am

Use the substr function.
http://www.php.net/manual/en/function.substr.php

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
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand


Return to mySQL & php coding

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron