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
PHP array Dynamic Add implementation code (the price of the most soil purchase system)