Re: strcmp()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 23, 2011, at 8:00 AM, tedd wrote:

> At 8:13 AM +0000 5/23/11, Ford, Mike wrote:
>> > -----Original Message-----
>> > From: tedd [mailto:tedd.sperling@xxxxxxxxx]
>> > >On Sat, 21 May 2011 09:26:02 -0400, tedd wrote:
>> > >>  The function strcmp() simply evaluates two strings and reports
>> > back -1, 0, or 1 depending upon their  alphabetical relationship.
>> > >
>>> >It might do that, but don't bet your horse on it.
>>> >
>>> ><http://se.php.net/manual/en/function.strcmp.php>
>>> >
>> > >/Nisse
>>> 
>>> It works that way for me.
>> 
>> Are you absolutely certain about that?
>> 
>>   echo strcmp('These are nearly equal', 'These are almost equal'), "\n";
>>   echo strcmp('different', 'unequal'), "\n";
>>   echo strcmp('b', 'a'), "<br />\n";
>> 
>> Result:
>> 
>>   13
>>   -17
>>   1
>> 
>> The description of the function merely says that the result is <0, 0 or >0
>> -- it makes no promises about the actual value when it is non-zero.
>> 
>> Mike
> 
> Mike:
> 
> That's interesting. Try the same comparisons here:
> 
> http://www.webbytedd.com/lcc/citw229/string-compare.php
> 
> For me they are 1, -1, and 1.
> 
> Someone with more smarts than me* will have to figure this one out.
> 
> Cheers,
> 
> tedd
> 
> PS: * I can hear the peanut gallery saying "That won't be hard."  :-)
> 
> -- 
> -------
> http://sperling.com/

Might that have something to do with the version of PHP running? 

Regards,

-Josh
____________________________________
Joshua Kehn | Josh.kehn@xxxxxxxxx
http://joshuakehn.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux