Paweł Stradomski wrote:
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
It also isn't any shorter:
if(str_endswith($path,'.php'))
vs.
if(substr($path,-4)=='.php')
Only if comparing to a static string, but not for this case:
if (substr($path, -strlen($extension)) ==
On Mon, 2008-07-21 at 22:06 +0200, Paweł Stradomski wrote:
> W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
> > It also isn't any shorter:
> >
> >if(str_endswith($path,'.php'))
> >
> >vs.
> >
> >if(substr($path,-4)=='.php')
>
> Only if comparing to a static string, but not
Jani Taskinen wrote:
Paweł Stradomski kirjoitti:
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
It also isn't any shorter:
if(str_endswith($path,'.php'))
vs.
if(substr($path,-4)=='.php')
Only if comparing to a static string, but not for this case:
if (substr($path, -
Paweł Stradomski kirjoitti:
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
It also isn't any shorter:
if(str_endswith($path,'.php'))
vs.
if(substr($path,-4)=='.php')
Only if comparing to a static string, but not for this case:
if (substr($path, -strlen($extension)) ==
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
> It also isn't any shorter:
>
>if(str_endswith($path,'.php'))
>
>vs.
>
>if(substr($path,-4)=='.php')
Only if comparing to a static string, but not for this case:
if (substr($path, -strlen($extension)) == $extension)
Readabi
Hi!
It also isn't any shorter:
if(str_endswith($path,'.php'))
vs.
if(substr($path,-4)=='.php')
Doesn't substr allocate new string for ".php"? Then endswith can have
one advantage of not requiring any new allocations. Not sure it's enough
to add it, but a point here to consider.
--
Brian Moon wrote:
Stan Vassilev | FM wrote:
I'm particularly for begins/endswith() function as I do this all over my
code and I'd appreciate the simplification and free extra performance.
I really don't mean to be rude here, but shorter and less typing !==
performance gain. The PHP string func
Stan Vassilev | FM wrote:
I'm particularly for begins/endswith() function as I do this all over my
code and I'd appreciate the simplification and free extra performance.
I really don't mean to be rude here, but shorter and less typing !==
performance gain. The PHP string functions are very fa
Surely substr_compare() does both begin & end easily enough.
Though the fact that it throws warnings is annoying.
Jared
> -Original Message-
> From: Stan Vassilev | FM [mailto:[EMAIL PROTECTED]
> Sent: 21 July 2008 13:18
> To: internals
> Subject: Re: [PHP-DEV] N
Hi,
ucfirst() isn't solving a pain point either. But we use it all the time (I
do at least).
I'm particularly for begins/endswith() function as I do this all over my
code and I'd appreciate the simplification and free extra performance.
Regards,
Stan Vassilev
I agree that many existing fu
I agree that many existing functions can be implemented with a
combination of others, but in this case it is really just one call. The
strlen() call is almost free, and in many cases you wouldn't even use
it. If you are looking for .php files, for example:
if(str_endswith($path,'.php'))
v
Hi,
Actually starts with and ends with is a very common case. I see your
concerns, but I can see instantly quite a lot of places in my code where I'd
use those. And I bet it'll be faster too.
Many of the string functions can be replicated with one-liners using other
string functions, same f
For the start of the string:
substr($haystack,0,strlen($needle)) == $needle
And for the end of the string:
substr($haystack,-strlen($needle)) == $needle
For case-insensitivity, just strtolower both.
Writing built-in functions for something that can be done with trivial
one-liners isn't s
Hi Martin,
first of all, thanks for you work! A few comments below.
Am Samstag, den 19.07.2008, 14:55 +0200 schrieb Martin Jansen:
> Attached you'll find a patch against PHP_5_3 that implements two new
> string functions:
>
> str_startswith(haystack, needle [, case_sensitivity])
That's in my op
14 matches
Mail list logo