Hi folks, I'm looking for a function, similar to str_replace that replaces just the first occurance of a specified string. I have found such a function:
However, this does not take into consideration of 'search from an initial position'.
My interest is with regard to replacing strings within a php array (for translation purposes) in phpBB language files:
'THIS_KEY' => 'My string',
'THIS_KEY_1' => 'My string 1',
'THIS_KEY_2' => 'My string 2',
I want to find the key within the file (I load the whole file into a string via file-get_contents), and from that point replace the English value (e.g. 'My string') with another. It is very important that only that particular value is replaced as further replacements could cause havoc.
For example the value 'View' could have a number of different translations in a language, depending on context.
Any 'views' on this would be most welcome! I admit to being a complete fool when it comes to regex.