Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php sort custom function

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

$a = array(3, 2, 5, 6, 1);

usort($a, "cmp");

foreach ($a as $key => $value) {
    echo "$key: $value
";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: print asociative array php 
Php :: laravel collection concat 
Php :: laravel eloquent get all 
Php :: wherejsoncontains laravel 
Php :: str_replace smarty template 
Php :: how to stop laravel server 
Php :: php has constant 
Php :: php sum of digits 
Php :: print array in php 
Php :: 419 page expired laravel 
Php :: check if the link is image or url php 
Php :: remove a specific element from an array php 
Php :: php superglobals 
Php :: laravel check if string is url 
Php :: laravel without global scope 
Php :: php realpath 
Php :: wordpress post type template 
Php :: laravel collection isempty 
Php :: php faker long text 
Php :: laravel create mode 
Php :: explode php all values to int 
Php :: check if string contains only whitespace php 
Php :: laravel multiple paginate 
Php :: laral db innodb 
Php :: guzzle http client 
Php :: php check if associative array 
Php :: check if file empty php 
Php :: php curl add user agent 
Php :: laravel exist 
Php :: laravel when condition 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =