note 123230 added to function.strcasecmp

From: Date: Sat, 13 Oct 2018 20:47:34 +0000
Subject: note 123230 added to function.strcasecmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-209436@lists.php.net to get a copy of this message
I didn't see any explanation in the documentation as to precisely how the positive/negative return values are calculated for unequal strings. After a bit of experimentation it appears that it's the difference in alphabetical position of the first character in unequal strings. For example, the letter 'z' is the 26th letter while the letter 'a' is the 1st letter: <?php $zappl = "zappl"; $apple = "apple"; echo strcasecmp($zappl, $apple); #outputs 25 [26 - 1] echo strcasecmp($apple, $zappl); #outputs -25 [1 - 26] ?> This might be incredibly obvious to most people, but hopefully it will clarify the calculation process for some others. ---- Server IP: 208.43.231.9 Probable Submitter: 78.144.203.160 ---- Manual Page -- http://php.net/manual/en/function.strcasecmp.php Edit -- https://master.php.net/note/edit/123230 Del: integrated -- https://master.php.net/note/delete/123230/integrated Del: useless -- https://master.php.net/note/delete/123230/useless Del: bad code -- https://master.php.net/note/delete/123230/bad+code Del: spam -- https://master.php.net/note/delete/123230/spam Del: non-english -- https://master.php.net/note/delete/123230/non-english Del: in docs -- https://master.php.net/note/delete/123230/in+docs Del: other reasons-- https://master.php.net/note/delete/123230 Reject -- https://master.php.net/note/reject/123230 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209436) next »