Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the algorithms of PHP

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

小编给大家分享一下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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report