: This article mainly introduces PHP big data addition. if you are interested in the PHP Tutorial, refer to it.
functionadd($a,$b){$a = strrev($a); $b = strrev($b); $tmp = 0; $tmp_c = 0; $count = ''; $len = strlen($a)>strlen($b)?strlen($a):strlen($b); for($i=0;$i<$len;$i++){ if(isset($a[$i]) && isset($b[$i])){ $tmp_c = $a[$i] + $b[$i] + $tmp; if($tmp_c > 10) { $tmp = 1; $count = substr($tmp_c,1).$count; } else { $tmp = 0; $count = $tmp_c.$count; } } elseif(isset($a[$i])) { $tmp_c = $a[$i] + $tmp; if($tmp_c > 10) { $tmp = 1; $count = substr($tmp_c,1).$count; } else { $tmp = 0; $count = $tmp_c.$count; } } elseif(isset($b[$i])) { $tmp_c = $b[$i] + $tmp; if($tmp_c > 10) { $tmp = 1; $count = substr($tmp_c,1).$count; } else { $tmp = 0; $count = $tmp_c.$count; } } } return$count; }
Copyright disclaimer: reprinted. please keep the document signature and link
The above introduces the PHP big data addition, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.