php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39962 Suggestion: substr_add function
Submitted: 2006-12-27 14:42 UTC Modified: 2012-08-10 18:43 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pjoe444 at hotmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pjoe444 at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-12-27 14:42 UTC] pjoe444 at hotmail dot com
Description:
------------
SUGGESTION to the PhP Group 
(I did not find any place for suggestions on the site:
the suggestion links seem to point here)

How about a  SUBSTR_ADD  function similar to substr_replace

substr_add (mixed string, string replacement, int start [, int length] )

example when handling time (in schedules etc)

$var=1245
$var= substr_add ($var, ':', 2);
                  $var value now 12:45

Yes-- you can split and add and rejoin strings, or probably use preg_replace, but I am surprised that such a simple useful facility does not seem to be available in PHP !  :-(          Thanks!  Peter Douglas

Reproduce code:
---------------
N/A

Expected result:
----------------
N/A


Patches

substr_insert.patch (last revision 2011-08-23 15:37 UTC by datibbaw@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-27 14:55 UTC] pjoe444 at hotmail dot com
( SUBTRACTION, on the other hand, does work simply enough with the current system:
with SUBSTR_REPLACE being able to replace a character with an empty string "" )
 [2011-08-23 14:05 UTC] datibbaw@php.net
The following patch has been added/updated:

Patch Name: substr_insert.patch
Revision:   1314108314
URL:        https://bugs.php.net/patch-display.php?bug=39962&patch=substr_insert.patch&revision=1314108314
 [2011-08-23 14:08 UTC] datibbaw@php.net
The following patch has been added/updated:

Patch Name: substr_insert.patch
Revision:   1314108530
URL:        https://bugs.php.net/patch-display.php?bug=39962&patch=substr_insert.patch&revision=1314108530
 [2011-08-23 14:28 UTC] arpad@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2011-08-23 14:28 UTC] arpad@php.net
substr_replace() already provides this when the length argument is 0.
 [2011-08-23 15:37 UTC] datibbaw@php.net
The following patch has been added/updated:

Patch Name: substr_insert.patch
Revision:   1314113875
URL:        https://bugs.php.net/patch-display.php?bug=39962&patch=substr_insert.patch&revision=1314113875
 [2012-08-10 18:43 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2012-08-10 18:43 UTC] nikic@php.net
Closing this, as it can be easily done with substr_replace() already:

    $var = substr_replace($var, ':', 2, 0);

Doesn't make much sense to add an extra function for this.
 [2012-08-10 18:43 UTC] nikic@php.net
-Summary: Suggestion: SUBSTR_ADD Function +Summary: Suggestion: substr_add function
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC