There is an array which has even elements. Some of them paired, and the other is not paired.
I wanna show the unpaired one.
Example1 : [9,3,9,3,9,7,9]
Expected : 7
Example2 : [1,3,1,2,2]
Expected : 3
I think the paired ones should be removed from the old array and move to new array...
Please help me... Thank you
Maybe something like this:
I decided to use array_splice() function to remove an element in array because it reindexes the whole array.
I don't know if I understand that correctly. Array [9, 9, 9] should output 9?
Also, I decided to use is_numeric() function in the if statement because array_search() function may return 0 which is equal to false. Instead of this you can use if ($pair !== false) which additionally checks if the return value of array_search is boolean.