Skip to content
Advertisement

Check if a value has duplicate and the other column is different in a multidimensional array in php?

I have multidimensional array like this.

JavaScript

My goal is to return error if there is a duplicate value of “SERIAL” and different “BRANCH”.

Any idea how to achieve this?

Advertisement

Answer

If you group the serials and branches then you can see if the unique count is more than one.
This will output all the duplicates not just the first.

JavaScript

Output:

JavaScript

https://3v4l.org/Qj98N

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