There are two multi-dimensional arrays:
$array1 = array( 0 => array("cancelled" => "0", "id"=>"65"), 1 => array("cancelled" => "1", "id"=>"33")); $array2 = array( 0 => array("cancelled" => "0", "id"=>"11"), 1 => array("cancelled" => "0", "id"=>"27"), 2 => array("cancelled" => "0", "id"=>"65")); How to elegantly merge them so that an array with elements from the first array and the second one comes out, but all the values were unique, not repeated?
If you use $ array3 = array_merge ($ array1, $ array2); it will turn out:
$array3 = array( 0 => array("cancelled" => "0", "id"=>"65"), 1 => array("cancelled" => "1", "id"=>"33") 2 => array("cancelled" => "0", "id"=>"11"), 3 => array("cancelled" => "0", "id"=>"27"), 4 => array("cancelled" => "0", "id"=>"65")); Need
$array3 = array( 0 => array("cancelled" => "0", "id"=>"65"), 1 => array("cancelled" => "1", "id"=>"33") 2 => array("cancelled" => "0", "id"=>"11"), 3 => array("cancelled" => "0", "id"=>"27")); P.S. The uniqueness of the value can be determined also by the field of the array of the value of 'id' - in my case, if id is the same then the values are the same