note 17835 deleted from function.substr-replace by jimw
| From: | jimw@php.net | Date: | Wed, 02 Jan 2002 11:20:04 +0000 |
| Subject: | note 17835 deleted from function.substr-replace by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24211@lists.php.net to get a copy of this message | ||
to replace the last occurence of a string in a string do this:
// This will remove the last occurence of test from $stack and make the new string $newstack
$stack = strrev("test is a test it is");
$needle = strrev("test ");
$needlelen = strlen($needle);
$needlepos = strpos($stack, $needle);
$newstack = strrev(substr_replace($stack, "", $needlepos, $needlelen));
now $newstack should be "test is a is"
might be useful... at least it was for me...