RE: [PHP] Simple String Handling
| From: | Cynic | Date: | Fri, 22 Dec 2000 15:13:10 +0000 |
| Subject: | RE: [PHP] Simple String Handling | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31581@lists.php.net to get a copy of this message | ||
couple of other ways to get the same result (cc'ing the list):
strstr( strrev( $str ) , '.' )
substr( $str , 0 , strcspn( $str , '.' ) )
strtok( $str , '.' )
their speed will differ in different situations (haystack length,
needle length, etc), that's why you can do it in more than one
way. and that's why you should benchmark them to avoid choosing
a wrong way.
At 15:58 22.12. 2000, o.cook@etoncollege.org.uk wrote the following:
--------------------------------------------------------------
>> -----Original Message-----
>> From: Cynic [mailto:cynic@mail.cz]
>> Sent: 22 December 2000 15:01
>> To: o.cook@etoncollege.org.uk
>> Subject: RE: [PHP] Simple String Handling
>>
>>
>> You're welcome.
>> BTW, there are lots of ways to achieve the same result, and
>> the one I proposed doesn't have to be the fastest / smartest.
>> And, of course, I forgot to quote the second argument in
>> strpos().
>
>Yes, there have been a few solutions posted; I'll probably choose the best
>for this situation! I had, of course, noticed that the period needed quoting
>;)
>
>Ollie
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz