Skip to content

array_diff_assoc BUG #19217

@sujrex

Description

@sujrex

Description

The following code:

on php8.x

<?php
$array1 = array("111" => ["color" => "green"]);
$array2 = array("111" => ["color" => "green"]);
$result = array_diff_assoc($array1, $array2);
print_r($result);

Resulted in this output:

Warning: Array to string conversion in script on line 4
Warning: Array to string conversion in script on line 4
Array
(
)

But I expected this output instead:

Array
(
)

on php7.4

<?php
$array1 = array("111" => ["color" => "green"]);
$array2 = array("111" => ["color" => "green"]);
$result = array_diff_assoc($array1, $array2);
print_r($result);

Resulted in this output:

Array
(
)

期待结果为:无论那个版本,当比较数组一致时,比较不应该报错,输出位空数组即可
Expect the result to be: no matter which version, when the comparison array is consistent, the comparison should not report an error, and the output bit empty array can be

PHP Version

PHP 8.x

Operating System

windows or linux

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