How can I unset pairs if match?
$pair = array(
array('number' => 1000),
array('number' => 2000),
array('number' => 3000),
array('number' => 2000),
array('number' => 2000)
);
if(sizeof($pair) >= 2) {
$i = 1;
$pair_A = $pair[0];
while(sizeof($pair) > $i) {
$pair_B = $pair[$i];
if($pair_A['number'] == $pair_B['number']) {
//with match
} else {
//no match
}
$i++;
unset($pair_B);
}
unset($pair_A);
}
The variable $pair_A
value is always repeated even though I unset it.
I want to have a result which is paired by two:
1. No Match = 1000 empty
2. Match with #4 = 2000 2000
3. No Match = 3000 empty
4. Match with #2 = 2000 2000
5. No Match = 2000 empty
If match, the corresponding value will also match like #2 and #3 (vice versa matching I guess).
Is this possible? Please help me I am having trouble in this flow several months already... I hope you can help me.