note 80925 added to language.types.string

From: Date: Thu, 07 Feb 2008 06:31:37 +0000
Subject: note 80925 added to language.types.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-135840@lists.php.net to get a copy of this message
I think there's not that much to string comparison as claiming date recognition: It's simply comparing ordinal values of the characters from the {0} to the {strlen-1} one. In this case <?php $a = '2007-11-06 15:17:48'; $b = '2007-11-05 15:17:48'; var_dump($a > $b); ?> mArIo@luigi ~ $: php test.php bool(true) here all characters match till it reaches position 9 (the "day") there, 6 has a bigger ord()inal value than 5 <?php $a = 'January 25th, 2008 00:23:38'; $b = 'Janury 24th, 2008 00:23:37'; // ($a > $b) === false ?> Here when we reach 'r' in "Janury" we see that "a" is "less" than "r" so the example would evaluate as ($a < $b) === true Here: <?php $a = 'February 1st, 2008 00:23:38'; $b = 'January 25th, 2008 00:23:38'; ?> as expected the letter "F" comes before "J" as an ordinal character, so $a is less than $b Even here: <?php var_dump('Z' > 'M'); //bool(true) ?> it gets confirmed that the string comparison operators >, <, =>, =<, == just do a ordinal character comparison starting from position {0} to the first difference or the end of the string. ---- Server IP: 69.147.83.197 Probable Submitter: 87.120.68.77 ---- Manual Page -- http://www.php.net/manual/en/language.types.string.php Edit -- https://master.php.net/note/edit/80925 Del: integrated -- https://master.php.net/note/delete/80925/integrated Del: useless -- https://master.php.net/note/delete/80925/useless Del: bad code -- https://master.php.net/note/delete/80925/bad+code Del: spam -- https://master.php.net/note/delete/80925/spam Del: non-english -- https://master.php.net/note/delete/80925/non-english Del: in docs -- https://master.php.net/note/delete/80925/in+docs Del: other reasons-- https://master.php.net/note/delete/80925 Reject -- https://master.php.net/note/reject/80925 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135840) next »