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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-20 18:43 UTC] martinkozak at martinkozak dot net
Mistake.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu May 28 09:01:24 2020 UTC