This article mainly introduces how php inserts an array without affecting the original sequence. The example analyzes the php array operation skills and has some reference value, for more information about how to insert arrays in php without affecting the original sequence, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
Function array_intsort ($ array, $ num) {$ array_right = $ array_left = array (); $ length = count ($ array); if ($ num <$ array [0]) {array_unshift ($ array, $ num); return $ array;} else {for ($ I = 0; $ I <$ length; $ I ++) {if ($ I + 1 <$ length) {if ($ array [$ I] <$ num & $ num <$ array [$ I + 1]) {$ array_right = array_slice ($ array, $ I + 1); $ array_left = array_slice ($ array, 0, $ I); $ array_left [] = $ num; break ;}} else {$ array_left = $ array; $ array_left [] = $ num ;}} return array_merge ($ array_left, $ array_right );}}
I hope this article will help you with php programming.