UTILITY

replace_last()

Replace only the last literal occurrence.

Signature

string replace_last(string $text, string $search, string $replace)

Example

replace_last('PHP PHP', 'PHP', 'ShortPHP'); // 'PHP ShortPHP'

Available from: 1.5.0

Reference navigation

Previous: replace_first()

Next: set_path()

Back to utilities