How do I get unique elements in my multidimensional array in PHP? -
this array:
array ( [0] => array ( [entity_id] => 1 [value] => new [label] => new ) [1] => array ( [entity_id] => 3 [value] => pending_payment [label] => pending payment ) [2] => array ( [entity_id] => 4 [value] => pending_paypal [label] => pending paypal ) [3] => array ( [entity_id] => 5 [value] => processing [label] => processing ) [4] => array ( [entity_id] => 6 [value] => complete [label] => complete ) [5] => array ( [entity_id] => 7 [value] => canceled [label] => canceled ) [6] => array ( [entity_id] => 8 [value] => closed [label] => closed ) [7] => array ( [entity_id] => 9 [value] => holded [label] => holded ) [8] => array ( [entity_id] => 10 [value] => payment_review [label] => payment review ) [9] => array ( [entity_id] => 11 [value] => new [label] => new ) [10] => array ( [entity_id] => 13 [value] => pending_payment [label] => pending payment )
update result of print_r. can see array[0] array[6] same. array[7] array[1]. how can rid of 1 of them ? thx
i tried smth this:
$input = $my_array $temp = $input; foreach ( $temp &$data ) { unset($data['id']); } $output = array_intersect_key($input, array_unique($temp));
but no result :( .
$result = array(); foreach ($myarray $array) { if (isset($result[$array['value']])) { continue; } $result[$array['value']] = $array; } print_r($result);
Comments
Post a Comment