: This article mainly introduces the bubble sorting and selection sorting of php simple sorting. For more information about PHP tutorials, see.
$ Arr [$ j]) {$ temp = $ arr [$ I]; $ arr [$ I] = $ arr [$ j]; $ arr [$ j] = $ temp; }}return $ arr ;} /*** select sort selectsort the key is to find the smallest array subscript * // $ arr = array (, 2,); // array, 6,100, 6,100, 6,100) first time // array (,) second time // array) third time // array (1, 2, 3, 4, 6,100, 7, 5) Fourth Time //... // array (7,100,) function fn_selectsort ($ arr) {for ($ I = 0; $ I <count ($ arr ); $ 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 smallest array subscript is found, replace the current array with the minimum array found. if ($ min! = $ I) {$ temp = $ arr [$ I]; $ arr [$ I] = $ arr [$ min]; $ arr [$ min] = $ temp;} return $ arr ;}?>
By: 19 materials
The above introduces the simple sorting of php bubble sorting and selection sorting, including the content, hope to be helpful to friends who are interested in PHP tutorials.