settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: Sum Reversed Numbers - PHP Array Task

+4 votes

Write a program that reads sequence of numbers, reverses their digits, and prints their sum.

Examples:

sum reversed numbers php array task

asked in PHP category by user Jolie Ann

1 Answer

+3 votes

My solution:

<?php

$arr = explode(" ", readline());

for ($i = 0; $i < count($arr); $i++) {
    $arr[$i] = strrev($arr[$i]);
}

echo array_sum($arr);
answered by user andrew
...