This article mainly introduces php's improvement on merging arrays with the same key values for a certain field. For more information, see
This article mainly introduces php's improvement on merging arrays with the same key values for a certain field. For more information, see
The following is the implementation code:
/***** Parameter description ** $ key names with the same key value ** $ array represents the original array ** $ start represents $ array [0] [$ key] ** $ newkey indicates the key name with the same key value **/function combine_same_val ($ array, $ start, $ key, $ newkey) {static $ new; foreach ($ array as $ k =>v v) {if ($ v [$ key] ==$ start) {$ new [$ v [$ newkey] [] = $ v; unset ($ array [$ k]); continue ;}} sort ($ array ); if (count ($ array )! = 0) {combine_same_val ($ array, $ array [0] [$ key], $ key, $ newkey);} return $ new ;}
,