php - Removing duplicate words in semicolon separated string -


i have long string in format:

hello; world; this; is; a; string; hello; of; some; words; 

it's semicolon + space separated. need remove duplicate words in string. resultant string should (with second hello; removed):

hello; world; this; is; a; string; of; some; words; 

how this?

here's example in php:

$string = "hello; world; this; is; a; string; hello; of; some; words;"; $string = implode("; ", array_unique(explode("; ", $string))); 

string contain new string: "hello; world; this; is; a; string; of; some; words;". if want string this: "hello world string of words" remove "; " implode parameters

edit: requested vihan1086, have posted original code below:

$string = "hello; world; this; is; a; string; hello; of; some; words;"; $matches = array_unique(explode("; ", $string)) $string = implode("; ", $matches); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -