note 119992 added to function.strncmp

From: Date: Thu, 06 Oct 2016 03:42:13 +0000
Subject: note 119992 added to function.strncmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-206781@lists.php.net to get a copy of this message
A note not included in the documentation: int strcmp ( string $str1 , string $str2 ) Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. My addendum: If str1 and str2 are not equal, and str1 is a sub-string of str2 or vise versa. The returned int value will be negative or positive indicating how many characters the difference is between the two strings in absolute terms. Example: <?php $str1 = "phpaaa"; $str2 = "php"; echo strcmp($str1, $str2); // 3 ?> since str2 = "php" is a sub-string of str1 = "phpaaa" and "phpaaa" is greater than "php" the returned value is positive and is 3 indicating how many characters the difference is between the two strings. If you replace the value of str1 with str2 the result will be -3 (negative) but still indicates the absolute difference which is 3 ---- Server IP: 72.52.91.14 Probable Submitter: 156.208.102.32 ---- Manual Page -- http://php.net/manual/en/function.strncmp.php Edit -- https://master.php.net/note/edit/119992 Del: integrated -- https://master.php.net/note/delete/119992/integrated Del: useless -- https://master.php.net/note/delete/119992/useless Del: bad code -- https://master.php.net/note/delete/119992/bad+code Del: spam -- https://master.php.net/note/delete/119992/spam Del: non-english -- https://master.php.net/note/delete/119992/non-english Del: in docs -- https://master.php.net/note/delete/119992/in+docs Del: other reasons-- https://master.php.net/note/delete/119992 Reject -- https://master.php.net/note/reject/119992 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206781) next »