note 49627 deleted from function.array-unique by levim

From: Date: Mon, 31 Aug 2015 03:07:17 +0000
Subject: note 49627 deleted from function.array-unique by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203524@lists.php.net to get a copy of this message
Note Submitter: trigger at e-mail dot ru ---- Just a simple implementation for JavaScript: <?php function array_unique(thearray) { thearray.sort(); //reset($thearray); newarray = new Array(); for (n=0;n<thearray.length;n++) { unique=1;//by default for(nn=0;nn<newarray.length;nn++) if (thearray[n] == newarray[nn]) { unique=0;//already exists break; } if(unique)//dont exists newarray.push(thearray[n]); } return newarray; } ?>

« previous php.notes (#203524) next »