[Solved] Sum Reversed Numbers - PHP Array Task

  

3
Topic starter

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

Examples:

sum reversed numbers php array task

1 Answer
2

My solution:

<?php
 
$arr = explode(" ", readline());
 
for ($i = 0; $i < count($arr); $i++) {
    $arr[$i] = strrev($arr[$i]);
}
 
echo array_sum($arr);
Share: