Skip to content

Invalid associative array containing duplicate keys #11451

Closed
@t-voet

Description

@t-voet

Description

The following code:

<?php
var_dump((new SQLite3(':memory:'))
	->query('SELECT 1 AS key,2 AS key')
	->fetchArray(SQLITE3_ASSOC));

Resulted in this output, for PHP 8.2.*:

array(2) {
  ["key"]=>
  int(1)
  ["key"]=>
  int(2)
}

But I expected this output instead, like PHP 8.1.20 and earlier:

array(1) {
  ["key"]=>
  int(2)
}

These duplicate keys are propagated by json_encode(), serialize(), ... resulting in invalid JSON, for example.

PHP Version

PHP 8.2.7

Operating System

FreeBSD 13.1-RELEASE-p6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions