php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15941 feature request for str_replace_first
Submitted: 2002-03-07 15:08 UTC Modified: 2002-07-25 16:01 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: tit dot petric at telemach dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.2 OS: all
Private report: No CVE-ID: None
 [2002-03-07 15:08 UTC] tit dot petric at telemach dot net
function str_replace_first($search, $replace, $subject)
{
        $retval = $subject;
        $pos = strpos($subject,$search);
        if ($pos !== false) {
                $retval = substr_replace($subject,$replace,$pos,strlen($search));
        }
        return $retval;
}


the above function would be useful in the str_functions, would probably be faster in c.. and i bet some people use something similar atleast once in their life :D

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-25 16:01 UTC] black@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 11:00:03 2025 UTC