php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38313 array_unique does not work
Submitted: 2006-08-03 12:19 UTC Modified: 2006-08-03 12:31 UTC
From: philsci at firstbrand dot co dot jp Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.1.4 OS: Windows XP Pro, Linux (redhat)
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 + 34 = ?
Subscribe to this entry?

 
 [2006-08-03 12:19 UTC] philsci at firstbrand dot co dot jp
Description:
------------
$arr_list = array( 'philsci@firstbrand.co.jp', 'philsci@firstbrand.co.jp' );
print_r( $arr_list ); echo '<br />';
array_unique( $arr_list );
print_r( $arr_list ); echo '<br />';

---------------

shows:

Array ( [0] => philsci@firstbrand.co.jp [1] => philsci@firstbrand.co.jp ) 
Array ( [0] => philsci@firstbrand.co.jp [1] => philsci@firstbrand.co.jp ) 

so, array_unique does not work at all.

Expected result:
----------------
$arr_list = array( 'philsci@firstbrand.co.jp', 'philsci@firstbrand.co.jp' );
print_r( $arr_list ); echo '<br />';
array_unique( $arr_list );
print_r( $arr_list ); echo '<br />';

---------------

should be shown as:

Array ( [0] => philsci@firstbrand.co.jp [1] => philsci@firstbrand.co.jp ) 
Array ( [0] => philsci@firstbrand.co.jp ) 


Actual result:
--------------
$arr_list = array( 'philsci@firstbrand.co.jp', 'philsci@firstbrand.co.jp' );
print_r( $arr_list ); echo '<br />';
array_unique( $arr_list );
print_r( $arr_list ); echo '<br />';


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-03 12:23 UTC] tony2001@php.net
RTFM:
array_unique() takes input array and **returns a new array without duplicate values**.
 [2006-08-03 12:26 UTC] philsci at firstbrand dot co dot jp
this issue is resolved when we explode an array only with \r in Windows and Linux, while \r\n nor \n work properly.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 11:02:27 2025 UTC