When I was learning PHP, I didn’t dare to get close to the algorithm. I was just afraid of disturbing my thoughts. Looking back now, it was really just that. hey-hey! Have any of you encountered such a situation? ha
- #Bubble sorting method
- $arr = array(12,45,89,3,24,55,223,76,22,11,89,2,4,5,28,112,20,434, 23,65,65,765,6,8,23,5,33,553,45,423,64,77,84,23);
- $tmp;
- for($i=0;$i for($j=0;$j if($arr[$j] > $arr[$j+1]) {
- $tmp = $arr[$j];
- $arr[$j] = $arr[$j+1];
- $arr[$j+1] = $tmp;
- }
- }
- }
-
-
-
- print_r($arr);
-
Copy code
|