Php array dynamic addition implementation code (price sorting of the most soil Group Buying System), Array Group Buying

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.