Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51757 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68651 invoked from network); 30 Mar 2011 22:35:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2011 22:35:45 -0000 Authentication-Results: pb1.pair.com header.from=soundasleep@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=soundasleep@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: soundasleep@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:65397] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/80-61875-040B39D4 for ; Wed, 30 Mar 2011 17:35:44 -0500 Received: by gyb11 with SMTP id 11so836942gyb.29 for ; Wed, 30 Mar 2011 15:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=M/X3KnwJv8RN40c0/JUUb457Y2M0Xb+OdW8dBJIeRhw=; b=OpV6+muWp+1Khavq1ISiOyX/wGr3hK6tXi1kTT75otR1+Ax7E7qnFLo9xt8pDJZhq+ 2KnHCRjTGAU7VR0FvNnAl5DO/3lGX51gvUvh8sciECkGCNU9EvzsHxJFrjTnZvjIQ+dm Ey+Q5FE+anRO+0qu3oIgTjuIvNjWSPZJTm9zk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=squrAcowmzJfCLmTmR9nQI/2+AOAirxQEb/P4+Aok6tITlG5qFobt5vyo856zrBLMD rNVNwZHVBWjIbULfsdsm1shUF6fqNuSpS+QJIQpQ3gua2F8fcZYnVPZSNTbcXPnU13dM Jos3Ix4pc0sqOZu5YoUHhg7841a9PJc7x0l4w= MIME-Version: 1.0 Received: by 10.236.73.202 with SMTP id v50mr2612670yhd.172.1301524541661; Wed, 30 Mar 2011 15:35:41 -0700 (PDT) Sender: soundasleep@gmail.com Received: by 10.147.169.6 with HTTP; Wed, 30 Mar 2011 15:35:41 -0700 (PDT) In-Reply-To: References: Date: Thu, 31 Mar 2011 11:35:41 +1300 X-Google-Sender-Auth: Wuh3f0-FjSNRsHbix2gpZWztm5g Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Adding a more logical string slicing function to PHP From: jevon@jevon.org (Jevon Wright) If substr() really was so bad, then surely we'd see userland implementations of str_slice() in every project? Jevon On Wed, Mar 30, 2011 at 7:06 PM, Dan Birken wrote: > My apologizes if I am bringing up a topic that has been discussed before, > this is my first time wading into the PHP developers lists and I couldn't > find anything particularly relevant with the search. > > Here is a bug I submitted over the weekend ( > http://bugs.php.net/bug.php?id=3D54387) with an attached patch that adds = a > str_slice() function into PHP. =A0This function is just a very simple str= ing > slicing function, with the logical interface of str_slice(string, start, > [end]). =A0It is of course meant to replace substr() as an interface for > string slicing. > > I detailed the reasons I submitted the patch in the bug a little bit, but > the main reason is that I think the substr() function is really overly > confusing and just not an intuitive method of string slicing, which is > exceedingly common functionality. =A0I realize we don't want to go around > adding lots of random little functions into the language that don't offer > much, but the problem with that is that if we have a function like substr= () > with an unusual and unintuitive interface, it becomes unchangeable due to > legacy issues and then you can never improve. =A0I think this particular > functionality is important enough to offer an updated interface. =A0In th= e bug > I also pointed to two related bugs that would be essentially fixed with t= his > patch. > > -Dan >