- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
function bigplus(){
$args = func_get_args();
$maxlength = 0;
$mlkey = 0;
$inmind = 0;
foreach($args as $key=>$arg){
$args[$key] = array_reverse(str_split($arg));
$length = count($args[$key]);
if($maxlength<$length){
$maxlength = $length;
$mlkey = $key;
}
}
for($pos=0; $pos<$maxlength; $pos++){
$c = 0;
for($i=0; $i<count($args); $i++){
if(!isset($args[$i][$pos])){
$args[$i][$pos]=0;
}
$c+=$args[$i][$pos];
}
$args[0][$pos] = $c+$inmind;
$inmind = floor(($args[0][$pos])/10);
$args[0][$pos] %= 10;
}
if($inmind>0){
$args[0][] = $inmind;
}
return implode(array_reverse($args[0]));
}