$arr [$j]) {$temp = $arr [$i]; $arr [$i] = $arr [$j]; $arr [$j] = $temp; }}} return $arr;} /** * Select sort sort selectsort key is to find the smallest array subscript *///$arr = Array (100,2,4,5,6,1,7,3); Array (1,2,4,5,6,100,7,3) the first time//array (1,2,4,5,6,100,7,3) The second time//array (1,2,3,5,6,100,7,4) The third time//array ( 1,2,3,4,6,100,7,5) Fourth times//...//array (1,2,3,4,5,6,7,100) Last function Fn_selectsort ($arr) {for ($i = 0; $i < count ($ar R); $i + +) {$min = $i; for ($j = $i +1; $j < count ($arr); $j + +) {if ($arr [$min] > $arr [$j]) {$min = $j; Find the smallest array subscript}}//If the minimum array subscript has been found, replace the current array with the smallest array found to replace if ($min! = $i) {$ temp = $arr [$i]; $arr [$i] = $arr [$min]; $arr [$min] = $temp; }} return $arr;}? >
By:19 Material
The above describes the simple sort of php bubble sorting and selection of sorting, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.