Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115079 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81852 invoked from network); 23 Jun 2021 21:09:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 21:09:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 777DF1804F3; Wed, 23 Jun 2021 14:28:31 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS; Wed, 23 Jun 2021 14:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1624483708; bh=FL3Rwu82PTVvGINzHRr6kJ9PcKvWGpu7ULoeKymQsEI=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=k18ccHeF0+VGKRZhqK7vlpS1QIhLEFjgIhQoiHehMuPCibWlMP2ht+EFKSuIf0LI3 DbDJurS/37op6GAaPWLOKE+vkdM491GgoLWjaKdGsBQQoS/Wt6T0YndjbwI/93wPcj co+zZUtoUO/1yHnLAxR2Wg1bLvcw22aZw1mcLkuM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([91.8.166.38]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M8ygY-1lsKOg0AKM-006AuH; Wed, 23 Jun 2021 23:28:28 +0200 To: Mike Schinkel , Sara Golemon , "G. P. B." , Hamza Ahmad Cc: PHP internals References: <012901d7683a$446a7ba0$cd3f72e0$@gmail.com> Message-ID: <7e2b946f-c302-5350-a6e6-1e06802c95a5@gmx.de> Date: Wed, 23 Jun 2021 23:28:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:vJjh8Pg5+lazjsZxIxDzhRY1o1zf3zbdSXmgxWYzQKG4zIe7G5W igioCuSgdZ8/ducgzzzUxAuw6ibSlXUD9zjhmiV8Zf385U+JZRCZ23vqCTYv4+Rab867gJS T2EeVLRbw5k9FuOYTsZM26HVbIntTXllSasJ0zrhZ0S8LMxtQiHrQHSdNEERKyHBVXaZ9zr 03KFVn+tN9qTLkN69pM4g== X-UI-Out-Filterresults: notjunk:1;V03:K0:+2G+sasmetk=:J6JX/lZf/S01ykZOG9rdUY e3zBPUEDXVjJonrCjTGLasOthR56kSJKWewtYLqOenbsUiVccWMyjB9WCutuKiOqM2TCzWexY Q8nkOFaNMRyIBLnfLedEj75jgiifS9piJ4Zcsu6Ot6EMQ7GviC3EchlzgelqGT2Y3M/RIPanc RfHfRhSdtetrJvcyxhhOgYB1ShA8lIe12WKePDc/L2YwX1+vThWt82pIf+8cAoxrvBkAC0HZ5 YJVFycbmdD3DjaooconmNLOf41U783JAGkAWQrPzADAEnvPwSlvdsDBJI/ScVM6AnDPYEjleN +KQa/f8/PF8khQ14gEeusvv2XZZqUAYQSAZ64i54GwRRBg/br20aZ34W8OhU2W0klz78EDkYn gHg1G45i+tn+TLPRsQcQTOu/wvay4Z8011+g+Zj1+2loSSGFyVfjjNy0B1TnPGFRMtvljbswD U9spGNZxBKf2VsVOcGAeXqmsUBkuQB69u6ydo6+Qxx2gcFaY39T5/7o/hVncQVksFM9QLlPpm NO4V4Tmo+cscxkS9QcJ7o6oFci239aeCh9YOoTxNbnjUygowRyNUOpHK659KEAp7R2XmZwR+L Fp9Vcbt1y3ucdY2/2q8prY5b3R6vFBIaTS30M9v30HDFSAS9y6tlNkdBhW9uHKkohuSwmCUkn fcSPg1hcZ0e5ijtH3nN2dDGO3mGeoMRScE9JtaztSDI7HbVe+vQ2gDNydziDvRFx9/ih6nGGg DU44uWMTJsRpMsBTKthPJt1Tt1aNbGsFeRn6jl7d4i4xZVsNMkQIir4Wa3PSs43X6XQamcKZy TAz8hiGYmIBTpzAkS/llR9z17SB1MJlK2+P/tu5azNCRfgYKIjQz0rIsf65zsI8DdQ3AQk4ZS uhj0mp8nGQL8361XcsvhkHJ1mxV7rxDTdEHqkT0kuCfyJiu/S1iRlZ0z2bTIewCSN6HpRdJ3Z I9VibcF2mox4MxnrQJJXgSidJ2BpBR5M8ZmzkSoMEXSm8O+xcCM7dMSHcdV2+6eMeFimIPm8C mRbzCgsPNrCn4pnAvbAtgqSNg45TEasqx9H1tVw7xLENw2kgTVBwbEpb0w4M1hzpZLDsaVkla 6C1MsoBVMifJzk+NYgmgqMoIjTeVjr+Py/b Subject: Re: [PHP-DEV] Introduce str_left/right In 8.1 From: cmbecker69@gmx.de ("Christoph M. Becker") On 23.06.2021 at 21:10, Mike Schinkel wrote: > Replying to both Sara's and G.P.B.'s emails below: > >> On Jun 23, 2021, at 12:48 PM, Sara Golemon wrote: >> >> Using some context, I would assume you mean this: >> >> function str_left(string $str, int $len): string { >> return substr($str, 0, $len); >> } >> >> function str_right(string $str, int $len): string { >> return substr($str, -$len); >> } >> >> If that's the case, then.... why? As you can see, the existing >> functionality available is trivial to write. >> >> Am I misunderstanding what these proposed functions should do, or am I >> underestimating the difficulty of typing a zero or negative sign on cer= tain >> keyboards? > > I can't speak for Hamza, but one reason I can see for why =E2=80=94 at l= east for str_right() =E2=80=94 is that using a negative index might not oc= cur to many people. Hell, I even forgot substr() worked that way until you= mentioned it. > > But, since objective evidence is better than opinion, a non-trivial numb= er of people have searched how to get the last 'n' characters from a strin= g in PHP, found the answer, and then went to the effort to upvote it on St= ackOverflow. If the 90-9-1 rule holds, then that's about 6200 people who = have been confused, searched and found the answer here: > > https://stackoverflow.com/questions/10542310/how-can-i-get-the-last-7-ch= aracters-of-a-php-string substr() is about bytes, not characters. They all may have upvoted the wrong answer. The only correct answer has just 17 upvotes. Christoph