php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78685 wong..
Submitted: 2019-10-18 10:02 UTC Modified: 2019-10-18 10:12 UTC
From: shan dot liu at msn dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.3.10 OS: all
Private report: No CVE-ID: None
 [2019-10-18 10:02 UTC] shan dot liu at msn dot com
Description:
------------
$a=array (
    'Fsku_id' => '30857',
);
$b=array (
    'Fsku_id' => '',
    'Fproduct_id' => '30857',
);
print_r(array_diff($a, $b));
output:
Array
(
)


Test script:
---------------
$a=array (
    'Fsku_id' => '30857',
);
$b=array (
    'Fsku_id' => '',
    'Fproduct_id' => '30857',
);
print_r(array_diff($a, $b));
output:
Array
(
)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-18 10:12 UTC] pmmaga@php.net
-Status: Open +Status: Not a bug
 [2019-10-18 10:12 UTC] pmmaga@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

As stated in the documentation, array_diff compares the values present in the arrays. If you want the check to include the keys, you should use array_diff_assoc.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Apr 21 21:01:24 2021 UTC