note 12566 modified in function.array-unique by vrana

From: Date: Tue, 17 Aug 2004 14:51:13 +0000
Subject: note 12566 modified in function.array-unique by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79767@lists.php.net to get a copy of this message
Following code copies unique values from MyArray to TempArray. Then copies non-empty elements from TempArray to UniqueArray. Not the most elegant solution, but it works. <?php $TempArray = array_unique($MyArray); while (list($index,$data)=each($TempArray)) { if (isempty($data)) { $UniqueArray[$index]=$data; } } ?> --was-- Following code copies unique values from MyArray to TempArray. Then copies non-empty elements from TempArray to UniqueArray. Not the most elegant solution, but it works. TempArray = array_unique($MyArray); while (list($index,$data)=each($TempArray)) { if (isempty($data)) { $UniqueArray[$index]=$data; } } http://php.net/manual/en/function.array-unique.php

« previous php.notes (#79767) next »