Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get rid off the repeat words from an array 1

Status
Not open for further replies.

dldl

Programmer
May 3, 2010
40
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".
 
Code:
foreach ($a as &$wordlist):
  $temp = explode(',', $wordlist);
  $temp = array_map('trim', $temp);
  $temp = array_unique($temp, SORT_STRING);
  $wordlist = $temp;
endforeach;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top