Thank you for the code but that doesn't output the result I am looking for. I didn't think about it when I originally posted but I probably should have listed what the output should be, for this example, so I will do that now. Given the following array, there are seven entries, which means there should be three marked as free, since it's buy one get one.
PHP Code:
$data[] = array('id'=>1961,'price'=>129.0000,'model'=>20);
$data[] = array('id'=>1962,'price'=>179.0000,'model'=>24);
$data[] = array('id'=>7047,'price'=>229.0000,'model'=>30);
$data[] = array('id'=>19650,'price'=>299.0000,'model'=>30);
$data[] = array('id'=>1989,'price'=>279.0000,'model'=>36);
$data[] = array('id'=>23112,'price'=>339.0000,'model'=>36);
$data[] = array('id'=>22399,'price'=>409.0000,'model'=>40);
The three would be:
This one since it is the lowest price and not part of a pair (where a pair refers to items with the same model numbers)
PHP Code:
$data[] = array('id'=>1961,'price'=>129.0000,'model'=>20);
This one since it is part of a pair and is the lowest of that pair
PHP Code:
$data[] = array('id'=>7047,'price'=>229.0000,'model'=>30);
This one since it is part of a pair and is the lowest of that pair
PHP Code:
$data[] = array('id'=>1989,'price'=>279.0000,'model'=>36);
So even though this one
PHP Code:
$data[] = array('id'=>1962,'price'=>179.0000,'model'=>24);
is lower in price than the last two above it, they take precedence since they are part of a pair.