1

How to remove duplicate in array if key have same name value and same file value(or file have empty value), i just want to remove index 2, please help me...

Array
(
    [0] => Array
        (
            [NAME] => E-Library
            [ID] => 27
            [FILE] => Lorem Ipsum
        )

    [1] => Array
        (
            [NAME] => ICT
            [ID] => 27
            [FILE] => lorem ipsum 2
        )

    [2] => Array
        (
            [NAME] => ICT
            [ID] => 27
            [FILE] => Empty
        )

    [3] => Array
        (
            [NAME] => Training of Trainer
            [ID] => 27
            [FILE] => Empty
        )
    [4] => Array
        (
            [NAME] => ICT
            [ID] => 27
            [FILE] => test
        )
)

i still confused, if use array unique just one name will display, i need data become like this,if have name same value but file have diffrent name data not remove, just data with same name and file empty. like this,...

Array
(
    [0] => Array
        (
            [NAME] => E-Library
            [ID] => 27
            [FILE] => Lorem Ipsum
        )

    [1] => Array
        (
            [NAME] => ICT
            [ID] => 27
            [FILE] => lorem ipsum 2
        )

    [2] => Array
        (
            [NAME] => Training of Trainer
            [ID] => 27
            [FILE] => Empty
        )
    [4] => Array
        (
            [NAME] => ICT
            [ID] => 27
            [FILE] => test
        )
)

1 Answers1

0

the docs are your friend: PHP Docs array_unique

Description: Takes an input array and returns a new array without duplicate values.

Note that keys are preserved. array_unique() sorts the values treated as string at first, then will keep the first key encountered for every value, and ignore all following keys. It does not mean that the key of the first related value from the unsorted array will be kept.

hammus
  • 2,602
  • 2
  • 19
  • 37
  • i still don't understand if use array_unique because data still display if file have diffrent name value...but thanks for quick response. – user2947193 Nov 02 '13 at 15:33