Skip to content
Advertisement

array_diff() function not showing correct result

array_diff() function not showing correct result:-

First Array:-

JavaScript

Second array:-

JavaScript

Output:

JavaScript

designation id column not showing in output result. if designation-id value is 1 then this index not showing in output otherwise it showing. is it bug or something else?

Advertisement

Answer

Since your arrays are associative arrays, so you need to use array_diff_assoc:-

JavaScript

Output:- https://3v4l.org/NKbuX

To check more descriptions and examples:- http://sg2.php.net/manual/en/function.array-diff-assoc.php

Why array_diff() not worked:- https://stackoverflow.com/a/4742438/4248328

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement