PHP array dynamically add implementation code (the price of the most soil purchase system), a number of groups to buy
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
http://www.bkjia.com/PHPjc/1134781.html www.bkjia.com true http://www.bkjia.com/PHPjc/1134781.html techarticle PHP Array dynamically add implementation code (the price of the most soil purchase system), a number of group purchase recently in the most soil purchase system price sequencing function, need to expand the $OC array, after testing ...