well,
I am not doing this code particularly for 'chandan' it could be anything.
The user enters his name, with spaces and all this thing, how can I manipulate this to do that.
It should only calculate the characters which are there in the name.
please suggets me .
and suppose,
i have 24 and i want to add it like = 2+4=6
this is done for any number which I get after above code (covert it in to single digit by adding.)
can the following function be used or any modification :
function math_calc($num){
$str = (string) $num;
while(strlen($str) > 1){
$num = $str[0];
for($i=1; $i<strlen($str); $i++){
$num += $str[$i];
}
$str = (string) $num;
}
return (int) $str;
}
$namank = math_calc($sum);
the $namank should be = 6