The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How do I order an array by neither ASC or DESC ?
I have an array of values such as follows: '4,8,8,7,4,7,8'
and I want to them order them in the following order: 7,4,8 so that the array orders like this: '7,7,4,4,8,8,8' Is there a function (in php or mysql) which defines custom sort orders? I have been searching the php manual but can't seem to find anything |
#2
|
|||
|
|||
You could use a CASE statement, like:
[SQL]ORDER BY (CASE WHEN field = '7' THEN 1 WHEN field = '4' THEN 2 WHEN field = '8' THEN 3 END) ASC[/SQL] I may have mistook you, you mean to order the rows in a particular order? |
#3
|
||||
|
||||
<a href="http://www.php.net/usort" target="_blank">http://www.php.net/usort</a>
|
#4
|
||||
|
||||
Farcaster, I would have never thought of using CASE, but it works very nicely - thanks!
El Muerte, I am going to try it with usort as well and see how it goes. thanks! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|