Im doing a php activity, that will compute the sum of given number of integer. Sample Output:
int number = 367;
Final output
16
16 is the total sum of 3+6+7.
Here's my Code:
$number = "367";
$int = 0;
for ($i = 0 ; $i < number.length(); $i++ ){
$char = number.charAt(i);
$int += Integer.parseInt(char1.toString());
}
echo $int;
Still i can't get the right answer anyone can help me? Thank you !
regards jay