Categories
How to remove duplicate values from an array?
There is a multidimensional array 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
$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 a Question
731 491 924 answers to any question