Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39147 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28332 invoked from network); 21 Jul 2008 20:52:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2008 20:52:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=dante@lorenso.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dante@lorenso.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lorenso.com from 72.249.142.200 cause and error) X-PHP-List-Original-Sender: dante@lorenso.com X-Host-Fingerprint: 72.249.142.200 mail.larkspark.com Linux 2.6 Received: from [72.249.142.200] ([72.249.142.200:36891] helo=mail.larkspark.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/E4-33868-A17F4884 for ; Mon, 21 Jul 2008 16:52:43 -0400 Received: from 99-147-139-38.lightspeed.allntx.sbcglobal.net ([99.147.139.38] helo=[192.168.1.67]) by lark01.larkspark.colo with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1KL2N3-00087D-RY; Mon, 21 Jul 2008 15:52:37 -0500 Message-ID: <4884F70C.2020109@lorenso.com> Date: Mon, 21 Jul 2008 15:52:28 -0500 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: jani.taskinen@iki.fi CC: =?UTF-8?B?UGF3ZcWCIFN0cmFkb21za2k=?= , internals@lists.php.net References: <4884A18D.7090104@dealnews.com> <4884B89A.7040508@lerdorf.com> <200807212206.53954.pstradomski@gmail.com> <4884EE17.6080501@sci.fi> In-Reply-To: <4884EE17.6080501@sci.fi> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] New string functions: str_startswith() and str_endswith() From: dante@lorenso.com ("D. Dante Lorenso") 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, -strlen($extension)) == $extension) >> Readability would also increase. > You people are funny.. I'd like to have such a function in PHP, but when you think about how easy it is to create without bloating the PHP core, it's easy enough to do without it. Here's what I do using my own string library: if (LS_Util_String :: ends_with($path, '.php')) { ... } It's a bit longer, but all my functions are longer for good reason: http://www.dantescode.com/2007/10/10/evolution-of-php-coder-naming-classes/ -- Dante