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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Thu Dec 26 22:01:28 2024 UTC