Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the algorithms of PHP

Shulou Source: shulou.com Published: 2022-06-03 05:44:27 11月18日 Update

小编给大家分享一下PHP有哪几个算法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

PHP几个算法整理

PHP冒泡

PHP二分法

PHP求素数

PHP乘法表

PHP冒泡法 示例

复制代码 代码如下:

//PHP冒泡 从小到大

function maopao(&$arr)

{

if(!empty($arr))

{

for($i=0;$i$arr[$j])

{

//开始交换

$temp = $arr[$i];

$arr[$i] = $arr[$j];

$arr[$j] = $temp;

}

}

}

return $arr;

}

}

php二分法查找 代码示例

复制代码 代码如下:

//二分法查找

function erfenfa($a,$arr)

{

print_r($arr);

if(!empty($a) && !empty($arr))

{

$start = 0;

$end = count($arr)-1;

$i = 0;

while($start $arr[$step])

{

$start = $step;

}

if($a < $arr[$step])

{

$end = $step;

}

}

}

}

php求素数 - 计算 a 到 b 之间的素数。 代码示例

复制代码 代码如下:

//php求素数 - 计算 a 到 b 之间的素数。

function sushu($a,$b)

{

if(!empty($a) && !empty($b))

{

if($b

Tags: Code multiplication multiplication tables examples primes outputs algorithms dichotomy articles between content recursion loops from small to big not much from small most more knowledge industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn MariaDB Huawei Shulou Tech Info