Quick strcmp query

This is a discussion on Quick strcmp query within the alt.comp.lang.php forums, part of the PHP Programming Forums category; What's the advantage of using strcmp as opposed to == for strings. For example I have : $a=array('dothis','dothat','...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-22-2008
No_One
 
Posts: n/a
Default Quick strcmp query


What's the advantage of using strcmp as opposed to == for strings.

For example I have :

$a=array('dothis','dothat','dosomethingelse');

$BLOCK_RUN=$a[date("w")];


if($BLOCK_RUN=='dothis')
etc etc....

Is there any reason to use this instead:

if(strcmp($BLOCK_RUN,'dothis')==0)
etc etc....


I don't see an advantage for strcmp here.....

ken
Reply With Quote
  #2 (permalink)  
Old 05-23-2008
Michael Fesser
 
Posts: n/a
Default Re: Quick strcmp query

..oO(No_One)

>What's the advantage of using strcmp as opposed to == for strings.


'==' tests for equality, strcmp() also for alphabetical order.

>For example I have :
>
>$a=array('dothis','dothat','dosomethingelse');
>
>$BLOCK_RUN=$a[date("w")];
>
>
>if($BLOCK_RUN=='dothis')
> etc etc....
>
>Is there any reason to use this instead:
>
>if(strcmp($BLOCK_RUN,'dothis')==0)
> etc etc....


Not in this case.

Micha
Reply With Quote
  #3 (permalink)  
Old 05-23-2008
No_One
 
Posts: n/a
Default Re: Quick strcmp query

On 2008-05-23, Michael Fesser <netizen@gmx.de> wrote:
> .oO(No_One)
>
>
> '==' tests for equality, strcmp() also for alphabetical order.
>
> Not in this case.
>
> Micha


Thanks for the info, it's appreciated

ken
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0