| PHP : How to replace only the first occurrence in a string with str_replace |
|
|
| Written by Oscar Sodani | |
| Wednesday, 14 June 2006 | |
|
For instance, if I had the string "X. Xavier Reynolds", and I wanted to easily replace just the first occurence of the X character, I would have to jump through hoops to split the string first to replace only the first occurrence. Luckily, I found a great snippet function posted by xinobit on the PHP documentation web site. I include it in almost all of my PHP apps: <??>
To use it, just call the function, like this: <?
|






