php編寫兩個32位以上數字相加
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title></title>
</head>
<?php
if($_GET){
$name1= $_GET['name1'];
$name2= $_GET['name2'];
$arr1 = str_split($name1);
$arr2 = str_split($name2);
$cou1 = count($arr1);
$cou2 = count($arr2);
$count = $cou1>=$cou2?$cou1:$cou2;
$sarr = array();
for($i=1;$i<=$count+1;$i++){
if($cou1-$i>=0){
$a = $arr1[$cou1-$i];
}else{
$a = 0;
}
if($cou2-$i>=0){
$b = $arr2[$cou2-$i];
}else{
$b = 0;
}
if(isset($sarr[$count-$i])){
$d = $sarr[$count-$i];
}else{
$d = 0;
}
$c = $a+$b+$d;
if($c>=10){
$carr = str_split($c.'');
$arr[$count-$i] = $carr[1];
$sarr[$count-$i-1] = $carr[0];
}else{
$arr[$count-$i] = $c;
}
}
ksort($arr);
$zong = implode('',$arr);
if(substr($zong,0,1) == 0){
$zong = substr($zong,1);
}
echo $zong;
}
?>
<body class="vdbg">
<form action="" method="get">
<input type="text" name="name1" value=""/>
<input type="text" name="name2" value=""/>
<input type="submit" name="submit" value="提交"/>
</form>
</body>
<?php
echo '<br/>';
function test_odd($var){
return($var & 8);
}
$a = array('a','b',2,3,4,5,6,7,8,9,11);
print_r(array_filter($a,"test_odd"));
echo '<br/>';
$b = array('b',1,12,2,3,4);
$c = array('a','b',2,6,7,8);
print_r(array_intersect($a,$b,$c));
?>
</html>