note 118757 deleted from function.usort by cmb
| From: | cmb@php.net | Date: | Sun, 13 Oct 2019 08:13:07 +0000 |
| Subject: | note 118757 deleted from function.usort by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212627@lists.php.net to get a copy of this message | ||
Note Submitter: kostya dot develop at gmail dot com
----
Now, in php 7, we can use the spaceship operator. For example lest sort array of words from element
string length:
<?php
$sampleArray = ['one', 'two', free', 'fore', 'five'];
usort($sampleArray, function($a, $b) {
return strlen($a) <=> strlen($b);
});