PHP removing subsequent occurrences of a word in a string, how would I do
this?
I'm pulling data, and the format in which its supplied isn't very neat.
For example, the data provides something along the lines of:
Volkswagen Golf 2.0 TDI Golf Match
Volkswagen Passat Passat SE
But all I want to do is remove the second (and any subsequent occurrence)
of repeated words, so that the string looks like:
Volkswagen Golf 2.0 TDI Match
Volkswagen Passat SE
So far, I've thought of making an array of words from the string, removing
the next row where the word has already been repeated, and then building
the string back from the array rows. Does anyone have any other (better)
ideas of doing this? Its part of a synchronisation service which is
already quite resource heavy, so making this process as efficient as
possible is important.
Thanks in advance for any ideas. Muchos Appreciatos! Ste
No comments:
Post a Comment