array-unique

array_unique and then renumbering keys [duplicate]

让人想犯罪 __ 提交于 2019-11-27 13:00:01
Possible Duplicate: Re-index numeric array keys I have an array as follows Array ( [0] => 15/11/2012 - 18/11/2012 [1] => 15/11/2012 - 18/11/2012 [2] => 15/11/2012 - 18/11/2012 [3] => 15/11/2012 - 18/11/2012 [4] => 19/12/2012 - 24/12/2012 [5] => 24/12/2012 - 01/01/2013 [6] => 24/12/2012 - 01/01/2013 [7] => 16/01/2013 - 01/02/2013 ) I am using array_unique to remove the duplicates which is giving me Array ( [0] => 15/11/2012 - 18/11/2012 [4] => 19/12/2012 - 24/12/2012 [5] => 24/12/2012 - 01/01/2013 [7] => 16/01/2013 - 01/02/2013 ) How can I change the keys so that they are consecutive - as below

How do I use array_unique on an array of arrays?

馋奶兔 提交于 2019-11-27 04:37:43
I have an array Array( [0] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [1] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [2] => Array ( [0] => 33 [user_id] => 33 [1] => 8 [frame_id] => 8 ) [3] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [4] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) ) As you can see key 0 is the same as 1, 3 and 4. And key 2 is different from them all. When running the array_unique function on them, the only left is Array ( [0] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) ) Any

Remove duplicate items from an array

风格不统一 提交于 2019-11-26 22:15:40
I use the line of code below to loop through a table in my database: $items_thread = $connection -> fetch_all($sql); And if I print the array out: print_r($items_thread); I will get this: Array ( [0] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [1] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [2] => Array ( [RecipientID] => 1 [RecipientScreenname] => Lau T [RecipientFirstname] => TK [RecipientEmail] => lau@xx.co.uk ) ) But I want to

array_unique and then renumbering keys [duplicate]

不羁的心 提交于 2019-11-26 17:43:11
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Re-index numeric array keys I have an array as follows Array ( [0] => 15/11/2012 - 18/11/2012 [1] => 15/11/2012 - 18/11/2012 [2] => 15/11/2012 - 18/11/2012 [3] => 15/11/2012 - 18/11/2012 [4] => 19/12/2012 - 24/12/2012 [5] => 24/12/2012 - 01/01/2013 [6] => 24/12/2012 - 01/01/2013 [7] => 16/01/2013 - 01/02/2013 ) I am using array_unique to remove the duplicates which is giving me Array ( [0] => 15/11/2012 - 18/11

Remove duplicate items from an array

ぃ、小莉子 提交于 2019-11-26 12:19:05
问题 I use the line of code below to loop through a table in my database: $items_thread = $connection -> fetch_all($sql); And if I print the array out: print_r($items_thread); I will get this: Array ( [0] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [1] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [2] => Array ( [RecipientID] => 1

How do I use array_unique on an array of arrays?

浪子不回头ぞ 提交于 2019-11-26 11:18:34
问题 I have an array Array( [0] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [1] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [2] => Array ( [0] => 33 [user_id] => 33 [1] => 8 [frame_id] => 8 ) [3] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) [4] => Array ( [0] => 33 [user_id] => 33 [1] => 3 [frame_id] => 3 ) ) As you can see key 0 is the same as 1, 3 and 4. And key 2 is different from them all. When running the array_unique function on them