jeturman Posted January 7, 2007 Share Posted January 7, 2007 I'm working with a database of 97,000 Russian words in MySQL. In another column is code that tells me where the accent falls on the word. I want to insert the accent mark in the right place. So in some cases I want to replace the first vowel with vowel + accent mark. In other cases it'll be the second or third vowel. Can I use str_replace to search for the first, second, or third vowel and replace just that one instance? Any other ideas would be appreciated. Link to comment https://forums.phpfreaks.com/topic/33212-how-to-replace-one-instance-in-a-string-instead-of-all/ Share on other sites More sharing options...
jeturman Posted January 7, 2007 Author Share Posted January 7, 2007 I've got it working using a loop going through letter by letter and then looping through all the possible vowels. Is there an easier way to do this? Link to comment https://forums.phpfreaks.com/topic/33212-how-to-replace-one-instance-in-a-string-instead-of-all/#findComment-155061 Share on other sites More sharing options...
effigy Posted January 7, 2007 Share Posted January 7, 2007 Try using[tt] preg_replace_callback [/tt]to determine the vowel's position. Link to comment https://forums.phpfreaks.com/topic/33212-how-to-replace-one-instance-in-a-string-instead-of-all/#findComment-155127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.