Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php usort two columns

$users=array(                                                       
    array("sex"=>0,"age"=>9),                              
    array("sex"=>0,"age"=>34),                             
    array("sex"=>1,"age"=>17),                             
    array("sex"=>0,"age"=>1),                              
    array("sex"=>1,"age"=>3)                              
);                                                                        
//sort first by sex, then by age
usort($users, function($a,$b){                                      
   return  ($a['sex'] == $b['sex']) ?                   
            $a['age'] < $b['age'] :                                   
            $a['sex'] < $b['sex'];                      
});  
Comment

PREVIOUS NEXT
Code Example
Php :: cURL error 60 : SSL certificate in Larvel in pusher or facebook authentication 
Php :: data showing in single option instead of multiple option from json array 
Php :: php if 2 files in dir unlink the olderst 
Php :: content for php.ini created manually 
Php :: modifier un formulaire php 
Php :: Namespace declaration statement has to be the very first statement or after any declare call in the script in file D:Xampphtdocsprojectsmulti_vender_siteappModelsUser.php on line 5 
Php :: laravel DomPDF live preview 
Php :: laravel add params form submission 
Php :: wp css deregister 
Php :: PHP code to redirect a user from a page to an alternate destination 
Php :: old codestar gallery 
Php :: connexion sql php/html 
Php :: New in initializers - PHP 8.1 
Php :: remove elements to this array 
Php :: dropdown in crud application YII 
Php :: salom 
Php :: wordpress give query a unique identity 
Php :: Code of getting sum of digits 
Php :: simple using mdb with php script PDO 
Php :: get_html_translation_table (PHP 4, PHP 5, PHP 7, PHP 8) get_html_translation_table — Returns the translation table 
Php :: set modes magento 2 
Php :: if laravel pagiantion not found error occured then 
Php :: imagelib thourgh class in codeigniter 
Php :: Set post views count using post meta 
Php :: union for rwos 
Php :: laravel command Retrieve a specific option 
Php :: installing php storm version 20 in ubuntu 
Php :: how to set selected value in dropdown using php 
Php :: Relationship 1-n multiple BACKPACK Laravel 
Php :: Codeingiter Pagination 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =