Skip to content

justutiz/php-remove-duplicates-in-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Remove duplicates and merge arrays by second level key.

Example:

removeDuplicates($firstArray, $secondArray, 'idproducts')

$firstArray
(
    [1] => Array
        (
            [idproducts] => 3633
            [name] => Aut et illum.
            [category] => 1
            [subcategory] => 2
            [price] => 262.31
        )

    [2] => Array
        (
            [idproducts] => 3756
            [name] => Eum minima at.
            [category] => 1
            [subcategory] => 1
            [price] => 331.14
        )
)

$secondArray
(
    [1] => Array
        (
            [idproducts] => 3756
            [name] => Eum minima at.
            [category] => 1
            [subcategory] => 1
            [price] => 331.14
        )
    [2] => Array
        (
            [idproducts] => 4485
            [name] => Eugtehnm mingweima aaat.
            [category] => 1
            [subcategory] => 1
            [price] => 331.14
        )
)

Returns

Array
(
    [1] => Array
        (
            [idproducts] => 3633
            [name] => Aut et illum.
            [category] => 1
            [subcategory] => 2
            [price] => 262.31
        )

    [2] => Array
        (
            [idproducts] => 3756
            [name] => Eum minima at.
            [category] => 1
            [subcategory] => 1
            [price] => 331.14
        )
    [3] => Array
        (
            [idproducts] => 4485
            [name] => Eugtehnm mingweima aaat.
            [category] => 1
            [subcategory] => 1
            [price] => 331.14
        )
)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages