Nov 11, 2011 #1 dldl Programmer Joined May 3, 2010 Messages 40 Location NZ Hi; How could i get rid off the repeat words from an array? Thanks eg; $a[]="the , think , this , that , the , their , that , the , the , those"; i just want the array reduce to "the, think, that,those".
Hi; How could i get rid off the repeat words from an array? Thanks eg; $a[]="the , think , this , that , the , their , that , the , the , those"; i just want the array reduce to "the, think, that,those".
Nov 12, 2011 1 #2 jpadie Technical User Joined Nov 24, 2003 Messages 10,094 Location FR Code: foreach ($a as &$wordlist): $temp = explode(',', $wordlist); $temp = array_map('trim', $temp); $temp = array_unique($temp, SORT_STRING); $wordlist = $temp; endforeach; Upvote 0 Downvote
Code: foreach ($a as &$wordlist): $temp = explode(',', $wordlist); $temp = array_map('trim', $temp); $temp = array_unique($temp, SORT_STRING); $wordlist = $temp; endforeach;
Nov 12, 2011 Thread starter #3 dldl Programmer Joined May 3, 2010 Messages 40 Location NZ Thanks a lot Upvote 0 Downvote