note 125067 added to function.sort

From: Date: Mon, 01 Jun 2020 19:02:51 +0000
Subject: note 125067 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-214706@lists.php.net to get a copy of this message
Let's say we have a list of names, and it is not sorted. <?php $names = array('Amin', 'amir', 'sarah', 'Somayeh', 'armita', 'Armin'); sort($names); // simple alphabetical sort print_r($names); ?> Result is : Array ( [0] => Amin [1] => Armin [2] => Somayeh // actually it's not sort alphabetically from here! [3] => amir // comparison is based on ASCII values. [4] => armita [5] => sarah ) If you want to sort alphabeticaly no matter it is upper or lower case: <?php sort($names, SORT_STRING | SORT_FLAG_CASE); print_r($names); ?> Result is: Array ( [0] => Amin [1] => amir [2] => Armin [3] => armita [4] => sarah [5] => Somayeh ) ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 91.98.82.5) ---- Manual Page -- http://php.net/manual/en/function.sort.php Edit -- https://master.php.net/note/edit/125067 Del: integrated -- https://master.php.net/note/delete/125067/integrated Del: useless -- https://master.php.net/note/delete/125067/useless Del: bad code -- https://master.php.net/note/delete/125067/bad+code Del: spam -- https://master.php.net/note/delete/125067/spam Del: non-english -- https://master.php.net/note/delete/125067/non-english Del: in docs -- https://master.php.net/note/delete/125067/in+docs Del: other reasons-- https://master.php.net/note/delete/125067 Reject -- https://master.php.net/note/reject/125067 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214706) next »