note 112473 added to function.array-unique

From: Date: Thu, 20 Jun 2013 07:14:17 +0000
Subject: note 112473 added to function.array-unique
Groups: php.notes 
Request: Send a blank email to php-notes+get-195296@lists.php.net to get a copy of this message
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)); } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 82.176.103.177 ---- Manual Page -- http://php.net/manual/en/function.array-unique.php Edit -- https://master.php.net/note/edit/112473 Del: integrated -- https://master.php.net/note/delete/112473/integrated Del: useless -- https://master.php.net/note/delete/112473/useless Del: bad code -- https://master.php.net/note/delete/112473/bad+code Del: spam -- https://master.php.net/note/delete/112473/spam Del: non-english -- https://master.php.net/note/delete/112473/non-english Del: in docs -- https://master.php.net/note/delete/112473/in+docs Del: other reasons-- https://master.php.net/note/delete/112473 Reject -- https://master.php.net/note/reject/112473 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195296) next »