Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115064 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38175 invoked from network); 23 Jun 2021 13:57:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 13:57:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 33F3C1804E3 for ; Wed, 23 Jun 2021 07:15:53 -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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 for ; Wed, 23 Jun 2021 07:15:52 -0700 (PDT) Received: by mail-pl1-f180.google.com with SMTP id c15so1240020pls.13 for ; Wed, 23 Jun 2021 07:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=p9CiWx5sS2cgHFA1CW/n+/K8pg6pP/bCZ8dhJb6GFEo=; b=HvKaCPMalx9ydCjorVBVg5X/LHxF0/PQfQY9VDO2ydoX36O5uQEvejszprgafOL6TB tfrEa37rldx/8Rrwj4jYgvl6x99jGqJrzyRTDv+i/f3c8vj3tlDo+p4J+tdzSzuSu1yy 6JkvjR1lkKs6phpBprlmGa7ENAkzgYrjMAgFijulad3vrOsvFi8V8shYAAEYmuA3bLlK fLET+rYnmewieyGxTE+jAZ9uwo9sNWq/8sYheg3TdWic31+JsD5o/n2dNJRKjRP3BKOX +aGlMO0tQvizxWkb9D5uB/f/zPHDMIAAPk/JrxfjiGJMCX974cely7yEh8cODof4V97s ZLqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding:thread-index:content-language; bh=p9CiWx5sS2cgHFA1CW/n+/K8pg6pP/bCZ8dhJb6GFEo=; b=AMnaSjNpVec1/FsFnoF719JetCMImO4AaEJ0IRojiLuMlsWYVnjnbhozxFmg/z+j14 qQaQMzAg7pa2x/ZsT8Yx3rPgp1+T7fGGxCyT9Y0V+77qaIapS6jKPVX1hPhyUqk0dTjN xNJ5UMJY29wmIlSOkig3pNbf+IuPbNcSN+yU+XE1WCMiOOzfcUt76pfzA7KfJtyFPBrS V8tALS3HnsQVsrom+I6b+zz688l5ohysf951unqFGDRvKo+U/JATBYHShpu6BvGkE/MA UAtWGdaL389oAlPS/jTFMfVPbfi5cDz8eD3MJpJMXs87pagxrML2P2l1kvNkBBJ+szpt oXow== X-Gm-Message-State: AOAM533J4WnUYsbLm3rCDpp6KeTCfEzBXYnwN1KBfki5Swof/gheXNwR 42B+5wkY89B1gXcxiQBdhzA7SiB083t7KQ== X-Google-Smtp-Source: ABdhPJxc1v2yMlRb6x5xnBwUcXhR4YAIMqHvmyx7MONzICn7ADauAot2a3NUVIVA6YPppQGNAi83Wg== X-Received: by 2002:a17:903:3091:b029:124:b117:5892 with SMTP id u17-20020a1709033091b0290124b1175892mr14658295plc.68.1624457750670; Wed, 23 Jun 2021 07:15:50 -0700 (PDT) Received: from DESKTOPQD1QNOQ ([45.152.182.93]) by smtp.gmail.com with ESMTPSA id a31sm74659pgm.73.2021.06.23.07.15.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jun 2021 07:15:50 -0700 (PDT) To: Date: Wed, 23 Jun 2021 19:15:45 +0500 Message-ID: <012901d7683a$446a7ba0$cd3f72e0$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AddoOZ6LkjRGdI6pS1SbWK/v/tVIOA== Content-Language: en-us Subject: Introduce str_left/right In 8.1 From: office.hamzaahmad@gmail.com ("Hamza Ahmad") Hello Internals, Since feature freeze for 8.1 is approaching, I want to request two useful string functions that exist in various languages-especially those that run on web servers and used in databases. These are respectively `left();` and `right();` Whether it is VBScript or MySQL, these two functions are available there. When I learnt PHP more than half a decade ago, I wondered why PHP had no functions that provide the same functionality as these two languages provide. Although both of these functions can be created in the userland, I request to build them in core for the following reasons: 1. They are standard functions in various languages. This article , available on Wikipedia, compares various languages in regard to string functions and recognizes left and right functions as a general term to make sense of the attitude of these functions. 2. To achieve the effect of these functions, one needs to use `substr();`. If these functions are introduced, it will be clear on the readers' level the actual purpose of the use of that string function. 3. There may be libraries that provide with the similar functionality; why not add this popular function to the core and make it available for everyone to use? IT will not require people to include such heavy libraries to their projects for such little and useful functions. 4. In the recent versions, PHP did include "str_contains", "str_ends_with", "str_starts_with", "array_key_first", and "array_key_last" functions. All of these functions are buildable in the userland, yet they have managed to make place to the core because of their popularity. Why not these two functions? If one has issues with the name choice, this is something that can be discussed. This request also takes inspiration from Kim Hallberg's proposal for `clamp();` function. His email encouraged me to put my word on the table. I am positive that senior developers would provide me with the feedback on my suggestion. I am also positive that my request will be added to 8.1. I thank you all for reading through my message and dropping a word. Best Regards Hamza Ahmad