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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Apr 23 22:01:31 2024 UTC