I have a PHP array with indexes, its values can be duplicated. I want to remove all duplicated indexes from this array:
array(3) {
[0]=>
array(5) {
["uid"]=>
int(1)
["title"]=>
string(26) "Title A"
["tstamp"]=>
string(10) "1580296755"
}
[1]=> // <----- should be removed, because it's tstamp is lower than it's duplicate
array(5) {
["uid"]=>
int(2)
["title"]=>
string(33) "Title B" // <----- duplicate value
["tstamp"]=>
string(10) "1580296797"
}
[2]=>
array(5) {
["uid"]=>
int(3)
["title"]=>
string(33) "Title B" // <----- duplicate value
["tstamp"]=>
string(10) "1580298366"
}
}
So, Index 1 and 2 with the same title "Title B" are duplicated. Only the one with the higher tstamp should be exists, all older ones with same title should be removed from array:
array(3) {
[0]=>
array(5) {
["uid"]=>
int(1)
["title"]=>
string(26) "Title A"
["tstamp"]=>
string(10) "1580296755"
}
[1]=>
array(5) {
["uid"]=>
int(3)
["title"]=>
string(33) "Title B"
["tstamp"]=>
string(10) "1580298366"
}
}
Hope someone understand me and can help to solve my problem.