I want to remove duplicates where either measurement or altunit matches another array, but ignoring if they're blank.
Array
(
[0] => Array
(
[id] => 2
[altunit] => %
[measurement] =>
)
[1] => Array
(
[id] => 3
[altunit] =>
[measurement] => 6
)
[2] => Array
(
[id] => 4
[altunit] => %
[measurement] =>
)
[3] => Array
(
[id] => 5
[altunit] =>
[measurement] => 6
)
[4] => Array
(
[id] => 6
[altunit] =>
[measurement] => 6
)
)
Becomes
Array
(
[0] => Array
(
[id] => 2
[altunit] => %
[measurement] =>
)
[1] => Array
(
[id] => 3
[altunit] =>
[measurement] => 6
)
)
Best I can come up with is:
$test = array ( 0 => array ( 'id' => '2', 'altunit' => '%', 'measurement' => NULL, ), 1 => array ( 'id' => '3', 'altunit' => NULL, 'measurement' => '6', ), 2 => array ( 'id' => '4', 'altunit' => NULL, 'measurement' => '6', ), 3 => array ( 'id' => '5', 'altunit' => NULL, 'measurement' => '6', ), 4 => array ( 'id' => '6', 'altunit' => NULL, 'measurement' => '6', ), );
$num = [];
foreach($test as $k => $v) $num[] = $v['measurement'];
But this only works for measurement, and removes the id and altunit keys.