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
Post a Comment