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','...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
..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 |