note 125471 added to function.uasort

From: Date: Thu, 29 Oct 2020 01:38:50 +0000
Subject: note 125471 added to function.uasort
Groups: php.notes 
Request: Send a blank email to php-notes+get-215668@lists.php.net to get a copy of this message
PHP version >= 7 <?php // Comparison function function cmp($a, $b) { return $a <=> $b; } // Array to be sorted $array = ['a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4]; print_r($array); // Sort and print the resulting array uasort($array, 'cmp'); print_r($array); ?> PHP version >= 7.4 <?php // Array to be sorted $array = ['a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4]; print_r($array); // Sort and print the resulting array uasort($array, fn($a, $b) => $a <=> $b); print_r($array); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.174 (proxied: 121.69.40.110) ---- Manual Page -- http://php.net/manual/en/function.uasort.php Edit -- https://master.php.net/note/edit/125471 Del: integrated -- https://master.php.net/note/delete/125471/integrated Del: useless -- https://master.php.net/note/delete/125471/useless Del: bad code -- https://master.php.net/note/delete/125471/bad+code Del: spam -- https://master.php.net/note/delete/125471/spam Del: non-english -- https://master.php.net/note/delete/125471/non-english Del: in docs -- https://master.php.net/note/delete/125471/in+docs Del: other reasons-- https://master.php.net/note/delete/125471 Reject -- https://master.php.net/note/reject/125471 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215668) next »