note 112473 deleted from function.array-unique by cmb

From: Date: Sun, 27 Oct 2019 08:42:24 +0000
Subject: note 112473 deleted from function.array-unique by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212801@lists.php.net to get a copy of this message
Note Submitter: Tim S. ---- I had to write a bunch of results to an array with a high probability of duplicates. The array was written to the file in chunks, using a for loop. It occurred to me that I often had blank lines in my file. Because this function preserve keys, I had gaps in my numeric keys. If you don't want to preserve keys, like me, you can use the following function. <?php function array_unique_ignore_keys(&$array, $sort_flags = SORT_STRING) { return array_values(array_unique($array, $sort_flags)); } ?>

« previous php.notes (#212801) next »