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
 [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: Fri May 29 17:01:40 2020 UTC