Home > Backend Development > PHP Tutorial > Example of swap sorting an array without using php api function_PHP tutorial

Example of swap sorting an array without using php api function_PHP tutorial

WBOY
Release: 2016-07-13 10:32:52
Original
942 people have browsed it

Copy code The code is as follows:

$arr = array(900, 20, 16, 50, -2, 10, 3);
$min = $max = 0;

for ($j=0;$j for ($i=0;$i if($arr[$i] > $arr[$i+1]){
$min = $arr[$i+1];
$arr[$i+1] = $arr [$i];
$arr[$i] = $min;
}
}
echo "The current array is:";print_r($arr);echo "
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/754034.htmlTechArticleCopy the code code as follows: $arr = array(900, 20, 16, 50, -2, 10, 3 ); $min = $max = 0; for ($j=0;$jcount($arr);$j++){ for($i=0;$icount($arr)-1;$i++){ if( $arr[$i] $arr[$i+1]){...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template