How to display particular key value array first in php -


this question has answer here:

i have array of values merged 2 array . given arrays ordered query. new merged array having in order array values.

now want order array values key 'desc' key named 'featured' contains numeric values

example

array (     [0] => stdclass object         (            featured=> 0,          shop_update =>a,b,c )    [1] => stdclass object         (            featured=> 1,          shop_update =>a,,c ),    [2] => stdclass object         (            featured=> 1,          shop_update =>a,c ), 

how order array featured desc ?

any help?

usort must help:

<?php function cmp($a, $b) {     if ($a->featured == $b->featured) {         return 0;     }     return ($a->featured < $b->featured) ? 1 : -1; }  usort($array, "cmp"); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -