Can any one let me know what's wrong with the above code :
the logic for the code is as:
user enters his name as : chandan tiwari
the function assign_value() used inthe code assigns the particular number to each character i.e.
c h a n d a n t i w a r i
2 3 4 5 67 8 9 0 1 2 4 5 (assuming)
the for loop should now calculate :
2+3+4+5+6+7+8+9+0+2+4+5=55
The $sum should have value=55 at the end.
The code is :
$name = $_POST['name'];
$sum = 0;
$name = (string) $name;
$name = strtolower($name);
$num = strlen($name);
for($i=0;$i<$num;$i++)
{
$name = $name[i];
$value = assign_value($name);
$sum = $sum + $value;
}
$name_number = $sum;
but the above code is not calculating the right value, it is giving me answer but that is not he right answer.
If you you want I can provide the function assign_value() also.
Please sugget me something.
Thanking you.