Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51745 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41262 invoked from network); 30 Mar 2011 06:06:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2011 06:06:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=birken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=birken@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: birken@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:36548] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/00-40685-F68C29D4 for ; Wed, 30 Mar 2011 01:06:40 -0500 Received: by vxb40 with SMTP id 40so860614vxb.29 for ; Tue, 29 Mar 2011 23:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=V3iCbXlz7a5N2RRpDcReRNKOEAZINV+WQA8/1+fzbNQ=; b=bJsnGg3uIUN5mKty53GiInkNjZgRw2ny7XiZpfAiFNA63Bwns0glHKs5hT+WFi+LfG PW88wxUMxSfns1E+ASLJQjjQljnkcHxij9oZk95ltg+bn0sUpUMBJYRwMUOyfx0bucsh Rnqeud4kxgzZw9FPQwJcVSLzn+86hL/FdnmMY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=W8LADIVu82XfqEeXdIHejayWIr+emyOSNSUno/NQqh1B5KMFZ9zwd3cXFO1zEuEEIy 7gwmKtdw4FrciFSD9ZLWqd/+OCE3ESL+FScCV6PnNOTBX2Ts4uy7z550digAOmT769IT ExWJeSu/bTL9MgR1UxW6tBkDCjgE8EXUklSGg= MIME-Version: 1.0 Received: by 10.52.66.163 with SMTP id g3mr985409vdt.94.1301465197364; Tue, 29 Mar 2011 23:06:37 -0700 (PDT) Received: by 10.52.157.200 with HTTP; Tue, 29 Mar 2011 23:06:37 -0700 (PDT) Date: Tue, 29 Mar 2011 23:06:37 -0700 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf307f3ba6c6c8b6049facfa29 Subject: Adding a more logical string slicing function to PHP From: birken@gmail.com (Dan Birken) --20cf307f3ba6c6c8b6049facfa29 Content-Type: text/plain; charset=ISO-8859-1 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=54387) with an attached patch that adds a str_slice() function into PHP. This function is just a very simple string slicing function, with the logical interface of str_slice(string, start, [end]). It 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. I 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. I think this particular functionality is important enough to offer an updated interface. In the bug I also pointed to two related bugs that would be essentially fixed with this patch. -Dan --20cf307f3ba6c6c8b6049facfa29--