note 118493 added to function.strncasecmp

From: Date: Tue, 15 Dec 2015 23:15:01 +0000
Subject: note 118493 added to function.strncasecmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-204379@lists.php.net to get a copy of this message
<?php $str1 = "red"; $str2 = "redent"; $test=strncasecmp($str1, $str2 , 3); if ($str1==$str2) { echo "$test"; } else { echo "$test" ; } ?> if we run the above script then we will get return 0, because first string $str1 = "red" and second $str2 = "redent" but in comparison i have set the first three character will try to match. as per condition if two string are equal then it will return 0. But in below example it will return greater than 0 because here is str1 is greater than str2. <?php $str1 = "redmyshirt"; $str2 = "redent"; $test=strncasecmp($str1, $str2 , 4); if ($str1==$str2) { echo "$test"; } else { echo "$test" ; } ?> as same if we run the below script it will return -1 because str1 is less than str2. <?php $str1 = "red"; $str2 = "redent"; $test=strncasecmp($str1, $str2 , 4); if ($str1==$str2) { echo "$test"; } else { echo "$test" ; } ?> ya..i think its easy to understand ---- Server IP: 72.52.91.14 Probable Submitter: 45.123.41.14 ---- Manual Page -- http://php.net/manual/en/function.strncasecmp.php Edit -- https://master.php.net/note/edit/118493 Del: integrated -- https://master.php.net/note/delete/118493/integrated Del: useless -- https://master.php.net/note/delete/118493/useless Del: bad code -- https://master.php.net/note/delete/118493/bad+code Del: spam -- https://master.php.net/note/delete/118493/spam Del: non-english -- https://master.php.net/note/delete/118493/non-english Del: in docs -- https://master.php.net/note/delete/118493/in+docs Del: other reasons-- https://master.php.net/note/delete/118493 Reject -- https://master.php.net/note/reject/118493 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204379) next »