View Single Post

  #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