php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51098 Strange array_flip() type handling
Submitted: 2010-02-20 18:41 UTC Modified: 2010-02-20 18:43 UTC
From: martinkozak at martinkozak dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.12 OS: FreeBSD 8.0
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: martinkozak at martinkozak dot net
New email:
PHP Version: OS:

 

 [2010-02-20 18:41 UTC] martinkozak at martinkozak dot net
Description:
------------
array_flip() converts some string values to integers (but some not) in non-associative array and assigns strange values, not value appropriate to last occurence.

Reproduce code:
---------------
---
From manual page: http://www.php.net/function.array-flip#Description
---
<?php
    $foo = array(
        '1',
        '1',
        '2&#836;',
        '2',
        '2',
        '2',
        '3',
    );
    
    var_dump(array_flip($foo));

Expected result:
----------------
array(3) {
  ["1"]=>
  int(1)
  ["2&#836;"]=>
  int(5)
  ["3"]=>
  int(6)
}


Actual result:
--------------
array(4) {
  [1]=>
  int(1)
  ["2&#836;"]=>
  int(2)
  [2]=>
  int(5)
  [3]=>
  int(6)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-20 18:43 UTC] martinkozak at martinkozak dot net
Mistake.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Sep 18 05:00:01 2025 UTC