|
Posted by Dotan Cohen on 10/21/50 11:22
I've seen this discussed before, but no solution seems to have ever
been suggested. I'd like to replace the first instance of a substring
in a string. So if we were to replace the first 'the' with 'a' in the
sentance
"Then the big bear ate the little cat in the north of the woods."
we would have:
"Then a big bear ate the little cat in the north of the woods."
I'm on PHP Version 4.3.11, but I can't seem to do anything useful with
the preg_replace() limit parameter, which is supposed to be on
php>=4.0.1
Does anybody have an example of working code that does this? I've
never asked for code before, but this time I think that I already DO
know what functions I need, I just can't seem to make it connect....
Side note, in google I couldn't find anything for php that would do
what I want, but I found several perl archives that have a solution.
If need be, I can paste that perl code. Maybe someone will be able to
translate it into php. Thanks!
Dotan
http://lyricslist.com/lyrics/artist_albums/274/jamiroquai.php
Jamiroquai Song Lyrics
Navigation:
[Reply to this message]
|