Php array dynamic addition implementation code (price sorting of the most soil Group Buying System), Array Group Buying
Recently, the price sorting function of the most popular group buying system needs to be expanded to the $ oc array. After testing, use the following method.
The core code is as follows:
<? Php $ now = time (); $ oc = array ('Team _ type' => 'normal', "begin_time <'{$ now }'", "end_time> '{$ now}'",); $ p = "p2"; $ pp1 = ""; $ pp2 = ""; $ now = time (); switch ($ p) {case "p1": $ pp1 = "team_price <10"; $ pp2 = ""; break; case "p2 ": $ pp1 = "team_price> 10"; $ pp2 = "team_price <50"; break; case "p3": $ pp1 = "team_price> 50 "; $ pp2 = "team_price <100"; break; case "p4": $ pp1 = "team_price> 100"; $ pp2 = "team_price < 200 "; break; case" p5 ": $ pp1 =" team_price> 200 "; $ pp2 =" "; break; default: $ pp1 = ""; $ pp2 = "";} if (! Empty ($ pp1) {array_push ($ oc, $ pp1);} if (! Empty ($ pp2) {array_push ($ oc, $ pp2);} print_r ($ oc);/* Ask hovertree.com */?>
Because it is a multi-condition query, you must first determine whether it is null and then add it to the array.
Recommended: http://www.cnblogs.com/roucheng/p/3528396.html