


PHP array dynamically adds code to achieve price sorting of the most earthly group buying system
Recently implementing the price sorting function of the Tutu group buying system, the $oc array needs to be expanded. After testing, the following method can be used.
The core code is as follows:
<?<span>php </span><span>$now</span>=<span>time</span><span>(); </span><span>$oc</span> = <span>array</span><span>( </span>'team_type' => 'normal', "begin_time < '{<span>$now</span>}'", "end_time > '{<span>$now</span>}'",<span> ); </span><span>$p</span>="p2"<span>; </span><span>$pp1</span>=""<span>; </span><span>$pp2</span>=""<span>; </span><span>$now</span> = <span>time</span><span>(); </span><span>switch</span> (<span>$p</span><span>) { </span><span>case</span> "p1": <span>$pp1</span>="team_price < 10"<span>; </span><span>$pp2</span>=""<span>; </span><span>break</span><span>; </span><span>case</span> "p2": <span>$pp1</span>="team_price > 10"<span>; </span><span>$pp2</span>="team_price < 50"<span>; </span><span>break</span><span>; </span><span>case</span> "p3": <span>$pp1</span>="team_price > 50"<span>; </span><span>$pp2</span>="team_price < 100"<span>; </span><span>break</span><span>; </span><span>case</span> "p4": <span>$pp1</span>="team_price > 100"<span>; </span><span>$pp2</span>="team_price < 200"<span>; </span><span>break</span><span>; </span><span>case</span> "p5": <span>$pp1</span>="team_price > 200"<span>; </span><span>$pp2</span>=""<span>; </span><span>break</span><span>; </span><span>default</span>: <span>$pp1</span>=""<span>; </span><span>$pp2</span>=""<span>; } </span><span>if</span>(!<span>empty</span>(<span>$pp1</span><span>)){ </span><span>array_push</span>(<span>$oc</span>,<span>$pp1</span><span>); } </span><span>if</span>(!<span>empty</span>(<span>$pp2</span><span>)){ </span><span>array_push</span>(<span>$oc</span>,<span>$pp2</span><span>); } </span><span>print_r</span>(<span>$oc</span><span>); </span><span>/*</span><span> 何问起 hovertree.com </span><span>*/</span>?>
Because it is a multi-condition query, you need to first determine whether it is empty, and then add it to the array.
Recommended: http://www.cnblogs.com/roucheng/p/3528396.html
The above introduces the dynamic addition of PHP arrays to realize the price sorting of the code for the most local group buying system, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

TheFiiOCP13cassetteplayerwasannouncedinJanuary.Now,FiiOisexpandingitsportfoliowithtwonewmodels-onewitharedfrontandonewithatransparentfront.Thelatternotonlyperfectlymatchestheretrocharmoftheangulardesign,butalso

The Klipsch Flexus Core 300 is the top model in the series and is positioned above the already available Flexus Core 200 in the company's soundbar line-up. According to Klipsch, this is the first soundbar in the world whose sound can be adapted to th

How to realize point-to-point communication through PHP and P2P protocol. With the development of the Internet, peer-to-peer (P2P) communication has gradually become an important communication method. Compared with the traditional client-server communication method, P2P communication has better stability and scalability. In this article, we will introduce how to use PHP with the P2P protocol to achieve peer-to-peer communication and provide corresponding code examples. First, we need to understand the basic principles of P2P communication. The P2P protocol allows multiple computers to directly

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

Shortly after Tesla launched the Model 3 Highland refresh towards the end of last year, the US federal EV tax incentive rules changed, cutting the potential discount in half for eligible buyers because of Tesla's use of Chinese LFP cells in the new M

When the HMD Skyline(available on Amazon for $499) was launched last month, it was released in two colors - Neon Pink and Twisted Black. They are now joined by a third color dubbed Blue Topaz. HMD Global has also announced an official case for the ph

There have been multiple reports about Qualcomm increasing the price of Snapdragon 8 Gen 4 compared to its current-gen flagship SoC. Digital Chat Station, a notable leakster, reported about it back in May, which was later reinforced with a separate r
