note 118756 deleted from function.usort by salathe
| From: | salathe@php.net | Date: | Mon, 01 Feb 2016 12:49:41 +0000 |
| Subject: | note 118756 deleted from function.usort by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204827@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
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);
});