{"id":8597,"date":"2021-08-23T23:51:37","date_gmt":"2021-08-23T20:51:37","guid":{"rendered":"https:\/\/elzero.org\/?p=8597"},"modified":"2022-08-07T07:02:27","modified_gmt":"2022-08-07T04:02:27","slug":"php-problems-solving-remove-duplicate-words-from-string","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/php-problems-solving-remove-duplicate-words-from-string\/","title":{"rendered":"Remove Duplicate Words From String"},"content":{"rendered":"<h3>\u0627\u0644\u062d\u0644<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-php\">\r\n\/\/ PHP Version 7.4.22 \r\n\r\n\/\/ Long Version\r\nfunction remove_duplicate_words_from($sentence) {\r\n\r\n  \/\/ Convert To Array\r\n  $wordsList = explode(\" \", $sentence);\r\n\r\n  \/\/ Return Unique Only\r\n  $uniqueOnly = array_unique($wordsList);\r\n\r\n  \/\/ Join Array Elements\r\n  $finalString = implode(\" \", $uniqueOnly);\r\n\r\n  return $finalString;\r\n}\r\n\r\n\/\/ Short Version\r\nfunction remove_duplicate_words_from($sentence) {\r\n  return implode(\" \", array_unique(explode(\" \", $sentence)));\r\n}\r\n\r\necho remove_duplicate_words_from(\"Hello Elzero Web Web Hello School\");\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>Remove Duplicate Words From String With PHP<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[],"class_list":["post-8597","post","type-post","status-publish","format-standard","hentry","category-problems-solving"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=8597"}],"version-history":[{"count":1,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8597\/revisions"}],"predecessor-version":[{"id":8598,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8597\/revisions\/8598"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=8597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=8597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=8597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}