Re: strcmp()?
| From: | Alexey Bovanenko | Date: | Mon, 23 May 2011 13:18:39 +0000 |
| Subject: | Re: strcmp()? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313098@lists.php.net to get a copy of this message | ||
I checked on php 5.2.4-2 (ubuntu5.12). It returns 1,-1,1
On Mon, May 23, 2011 at 4:00 PM, tedd <tedd@sperling.com> wrote:
> At 8:13 AM +0000 5/23/11, Ford, Mike wrote:
>
>> > -----Original Message-----
>> > From: tedd [mailto:tedd.sperling@gmail.com]
>> > >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/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
With regards,
Alexei Bovanenko