PHPize Online / SQLize Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy
Copy Format Clear
<?php function bigSum(string $a, string $b): string { $a_arr = array_reverse(str_split($a)); $b_arr = array_reverse(str_split($b)); $res = []; $l = max(count($a_arr), count($b_arr)); for ($c=0; $c<$l; $c++) { $r = ($a_arr[$c] ?? 0) + ($b_arr[$c] ?? 0); if ($r < 10) $res[] = $r; else $res[] = $r % 10; } return implode('', array_reverse($res)); } echo 13 % 10; echo bigSum('1000000000000000000000000000001','465');
Show:  
Copy