Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39154 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41892 invoked from network); 21 Jul 2008 21:40:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2008 21:40:24 -0000 Authentication-Results: pb1.pair.com header.from=brianm@dealnews.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=brianm@dealnews.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain dealnews.com designates 72.5.90.27 as permitted sender) X-PHP-List-Original-Sender: brianm@dealnews.com X-Host-Fingerprint: 72.5.90.27 smtp.dealnews.com Linux 2.5 (sometimes 2.4) (4) Received: from [72.5.90.27] ([72.5.90.27:42976] helo=smtp.dealnews.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/77-33868-74205884 for ; Mon, 21 Jul 2008 17:40:24 -0400 Received: (qmail 23100 invoked from network); 21 Jul 2008 21:40:19 -0000 Received: from unknown (HELO mail.dealnews.com) (10.1.10.7) by -H with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Jul 2008 21:40:19 -0000 Received: (qmail 3551 invoked from network); 21 Jul 2008 21:40:19 -0000 Received: from h105.248.18.98.static.ip.windstream.net (HELO macdough.local) (brianm@98.18.248.105) by -H with ESMTPA; 21 Jul 2008 21:40:19 -0000 Message-ID: <48850242.5040206@dealnews.com> Date: Mon, 21 Jul 2008 16:40:18 -0500 User-Agent: Thunderbird/3.0a2pre (Macintosh; 2008071703) MIME-Version: 1.0 To: PHP Developers Mailing List References: <4884A18D.7090104@dealnews.com> <4884B89A.7040508@lerdorf.com> <200807212206.53954.pstradomski@gmail.com> In-Reply-To: <200807212206.53954.pstradomski@gmail.com> 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: brianm@dealnews.com (Brian Moon) 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)) == $extension) > > Readability would also increase. > 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/