Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rogervila/bfebef1333a2275d28f72829611d2228 to your computer and use it in GitHub Desktop.
Save rogervila/bfebef1333a2275d28f72829611d2228 to your computer and use it in GitHub Desktop.
array_diff() error when passing multidimensional arrays
<?php
$a = [
'a' => [
'b' => 'Hello',
],
];
$b = [
'a' => [
'b' => 'Goodbye',
],
];
$result = array_diff($a, $b);
var_dump($result);
/*
PHP 7.4 error:
PHP Notice: Array to string conversion in file.php on line...
array(0) {
}
PHP 8.0 error:
PHP Warning: Array to string conversion in file.php on line...
array(0) {
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment