Re: New string functions: str_startswith() and str_endswith()
| From: | Brian Moon | Date: | Mon, 21 Jul 2008 21:40:18 +0000 |
| Subject: | Re: New string functions: str_startswith() and str_endswith() | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-39154@lists.php.net to get a copy of this message | ||
Paweł Stradomski wrote:
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:In our code base, we have a nice file called string.php that has every variation of string functions not covered by the core in it. We add stuff as we need it. I break strings on the space nearest a given length in 80% of all code that runs on my server. But, I don't expect a PHP built in to do it. If you are worried about performance, you could make a PECL Strings package for all the stuff that the core does not do. Then, your code can be readable and neat like you want. Hmm, perhaps there is a need for a "standard" (widely used?) PHP (non-OO) package that filled in the gaps that the core does not provide. Make it non-OO so that it looks and acts like the core as much as possible. In my "spare time" I will start this. =) -- Brian Moon Senior Web Engineer ------------------------------ When you care enough to spend the very least. http://dealnews.com/It also isn't any shorter:Only if comparing to a static string, but not for this case: if (substr($path, -strlen($extension)) == $extension) Readability would also increase.if(str_endswith($path,'.php'))vs.if(substr($path,-4)=='.php')