PHP array Dynamic Add implementation code the price order of the most soil purchase system

Source: Internet
Author: User
Recently in the implementation of the most soil purchase system price ordering function, the $OC array needs to be extended, tested with 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"; $pp 1=""; $pp 2=""; $now= Time(); Switch($p) {  Case"P1":$pp 1= "Team_price < 10"; $pp 2="";  Break;  Case"P2":$pp 1= "Team_price > 10"; $pp 2= "Team_price < 50";  Break;  Case"P3":$pp 1= "Team_price > 50"; $pp 2= "Team_price < 100";  Break;  Case"P4":$pp 1= "Team_price > 100"; $pp 2= "Team_price < 200";  Break;  Case"P5":$pp 1= "Team_price > 200"; $pp 2="";  Break; default:$pp 1=""; $pp 2=""; } if(!Empty($pp 1)){ Array_push($oc,$pp 1); } if(!Empty($pp 2)){ Array_push($oc,$pp 2); } Print_r($oc); /*how to ask Hovertree.com*/?>

Because it is a multi-conditional query, it is necessary to determine whether it is empty before adding it to the array.

Recommendation: http://www.cnblogs.com/roucheng/p/3528396.html

The above describes the PHP array dynamic add implementation code the most soil purchase system price sequencing, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.