UTILITY

replace_first()

Replace only the first literal occurrence.

Signature

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

Example

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

Available from: 1.5.0

Reference navigation

Previous: remove()

Next: replace_last()

Back to utilities