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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: philsci at firstbrand dot co dot jp
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 13:01:27 2024 UTC