Skip to content

Magento 2: Remove Duplicates From The Collection

I have a custom model with three fields, i.e id, city and region.
How can I remove duplicates from the region column when querying the table?
How can I group all the cities under the same region?
I have pasted the response from the model below

Array
(
[0] => Array

    (   [city] => City 1
        [region] => Region 1
    )

[1] => Array

    (   [city] => City 2
        [region] => Region 1
    )

[2] => Array
    (   [city] => City 3
        [region] => Region 1
    )

[3] => Array
    (
        [city] => City 4
        [region] => Region 1
    )

)