Home >Backend Development >PHP Tutorial >不使用php api函数实现数组的交换排序示例_PHP

不使用php api函数实现数组的交换排序示例_PHP

WBOY
WBOYOriginal
2016-06-01 11:54:43924browse

复制代码 代码如下:
$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 "当前数组为:";print_r($arr);echo "
";
}

Statement:
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