I have an array with four columns (divided by ";") per index number. The data is coming from a csv file.
Example Data:
John = Firstname
Doe = Lastname
Playground = Description
[email protected] = Email
print_r($dataArray);
Array
(
[0] => John;Doe;Playground;[email protected]
[1] => John;Doe;Playground test;[email protected]
[2] => John;Doe;test Playground;[email protected]
[3] => Johnny;Dawson;Test Area;[email protected]
)
Now I want to remove the duplicates with array_unique.
But I only want to compare the "firstname" and the "lastname".
If the firstname and the lastname has multiple results then remove the duplicate entry.
In this case [1] and [2]
$finalArray = array_unique($dataArray);
array unique will only work if all rows have the same data e.g.
[0] => John;Doe;Playground;[email protected]
[1] => John;Doe;Playground;[email protected]
Goal: Final result
Array
(
[0] => John;Doe;Playground;[email protected]
[1] => Johnny;Dawson;Test Area;[email protected]
)
What is a good way to handle this case?