S
S
sugarufc2015-05-10 11:18:00
PHP
sugarufc, 2015-05-10 11:18:00

How to remove duplicate values ​​from an array?

There is a multidimensional array 9be2e5ce47c742b48eec54eddc5be41f.jpg
need to remove duplicate elements, ie. so that only two values ​​remain Polo and Nike.
PS array_unique() is not suitable!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
6
65536, 2015-05-10
@sugarufc

$has = array();
$output = array();

foreach ( $input as $data )
{
    if ( !in_array($data['clothes_name'], $has) )
    {
        $has[] = $data['clothes_name'];
        $output[] = $data;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question