基本数据结构和php内置函数实现
二分查找函数
//二分查找(数组里查找某个元素)
function bin_sch($array, $low, $high, $k){
if ($low $mid = intval(($low+$high)/2);
if ($array[$mid] == $k){
return $mid;
}elseif ($k return bin_sch($array, $low, $mid-1, $k);
}else{
return bin_sch($array, $mid+1, $high, $k);
}
}
return -1;
}
顺序查找函数的实现
//顺序查找(数组里查找某个元素)
function seq_sch($array, $n, $k){
$array[$n] = $k;
for($i=0; $iif($array[$i]==$k){
break;
}
}
if ($ireturn $i;
}else{
return -1;
}
}
线性表的删除函数的实现
//线性表的删除(数组中实现)
function delete_array_element($array, $i)
{
$len = count($array);
for ($j=$i; $j$array[$j] = $array[$j+1];
}
array_pop($array);
return $array;
}
冒泡排序函数的实现:
//冒泡排序(数组排序)
function bubble_sort($array)
{
$count = count($array);
if ($count
for($i=0; $ifor($j=$count-1; $j>$i; $j--){
if ($array[$j] $tmp = $array[$j];
$array[$j] = $array[$j-1];
$array[$j-1] = $tmp;
}
}
}
return $array;
}
快速排序函数实现
//快速排序(数组排序)
function quicksort($array) {
if (count($array)
$key = $array[0];
$left_arr = array();
$right_arr = array();
for ($i=1; $i
else
$right_arr[] = $array[$i];
}
$left_arr = quicksort($left_arr);
$right_arr = quicksort($right_arr);
return array_merge($left_arr, array($key), $right_arr);
}
PHP内置字符串函数实现
//------------------------
// PHP内置字符串函数实现
//------------------------
//字符串长度
function strlen($str)
{
if ($str == '') return 0;
$count = 0;
while (1){
if ($str[$count] != NULL){
$count++;
continue;
}else{
break;
}
}
return $count;
}
//截取子串函数实现
function substr($str, $start, $length=NULL)
{
if ($str=='' || $start>strlen($str)) return;
if (($length!=NULL) && ($start>0) && ($length>strlen($str)-$start)) return;
if (($length!=NULL) && ($startstrlen($str)+$start)) return;
if ($length == NULL) $length = (strlen($str) - $start);
if ($start for ($i=(strlen($str)+$start); $i$substr .= $str[$i];
}
}
if ($length > 0){
for ($i=$start; $i

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
