Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51750 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95884 invoked from network); 30 Mar 2011 14:09:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2011 14:09:00 -0000 Authentication-Results: pb1.pair.com header.from=phpwnd@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=phpwnd@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: phpwnd@gmail.com X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:36824] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/B2-07269-B79339D4 for ; Wed, 30 Mar 2011 09:09:00 -0500 Received: by fxm1 with SMTP id 1so1138878fxm.29 for ; Wed, 30 Mar 2011 07:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ghPwsDMLm/nflFQ0faVMjf+6px6BXUItbN+9w+lS35E=; b=osZePjyiojuHbE6YfIRAFGxWyvogEgsZvzZlmUMSTJFcvzm1+D1R+PAq2kdq+g4sup SZPWy9smS5MjsbsvViK2RvtDUpx5CuoqOLdpGco1b2E/EnLCRVtnzrCxdcxBJuf9omOS 9jsR6qYAdwk8mmYIQC2j95oSB3IbJyjWNimdE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=AcY41JIMj405UFBrZKnemBRdEj41VQDG8q7bJSYCTHY0Q7MDhXJE2ochlgPPqn7vAy 9DA/3DMExIhNby+ql6jIa0MZlRMTZmQZKuuYBeFRcQFbFOqMIq+douWO6hnxEjQcJOF3 h4ihKBUrPForAadOrBu8HjfAh07h1RAMr0c98= MIME-Version: 1.0 Received: by 10.223.14.137 with SMTP id g9mr1371677faa.8.1301494136601; Wed, 30 Mar 2011 07:08:56 -0700 (PDT) Received: by 10.223.116.73 with HTTP; Wed, 30 Mar 2011 07:08:56 -0700 (PDT) In-Reply-To: References: <4D92CC38.5040900@toolpark.com> Date: Wed, 30 Mar 2011 16:08:56 +0200 Message-ID: To: Hannes Landeholm Cc: Dan Birken , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Adding a more logical string slicing function to PHP From: phpwnd@gmail.com (Josh Davis) On 30 March 2011 15:05, Hannes Landeholm wrote: > Parsing is a problem in many real-world > problems and substr currently works great for that purpose. That's funny because the first thing I thought when I read the original mail was "oh that would be great for parsing." In fact, I've just grep'ed through some code from a rich text parser I've been working on and at first glance there are at ~5 occurences of substr() that I would replace with str_slice(). There are also 15+ occurences of substr() that would remain untouched. It's not black-and-white, sometimes you want N characters starting from pos X, and other times you want to cut the text from pos X and pos Y, and that's where str_slice() would be welcome. This thread shouldn't be a criticism of substr(), it would be pointless. Its signature and behaviour will never change, unless perhaps around April 1st as a practical joke on the millions of websites it would break. The question is: is str_slice() useful, does it fill a need and should it be included into PHP? -JD