时间:2021-07-01 10:21:17 帮助过:5人阅读
$array_a = array(2,5,7);
$array_b = array(1,2,3,8,9);
$length_a = count($array_a);
$length_b = count($array_b);
$array_c = array();
$a = 0;
$b = 0;
$time_a = microtime(true);
while(true){
if($a == $length_a || $b == $length_b)
break;
if($array_a[$a] <= $array_b[$b]){
$array_c[] = $array_a[$a];
++$a;
}else{
$array_c[] = $array_b[$b];
++$b;
}
}
if($a == $length_a){
while($b < $length_b){
$array_c[] = $array_b[$b++];
}
}
else{
while($a < $length_a){
$array_c[] = $array_a[$a++];
}
}
//var_dump($array_c);$result_a = microtime(true) - $time_a;
//2.$time_b = microtime(true);
$array_c = array();
$array_c = array_merge($array_a, $array_b);
sort($array_c);
//var_dump($array_c);$result_b = microtime(true) - $time_b;
echo ($result_b - $result_a) > 0 ? 1 : 0;
?>
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了php-logic-1,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。