In terms of the algorithm, you just need to:
Create an empty array.
Scan each element of the array in the original array, creating a new element (in an empty array) for each new make / model and adding a dimensional array.
If you already have a brand / model record, just add the size to the sub-matrix, if not already presented.
You can implement this as follows (roughly, but it works):
<?php
$sourceArray = array(array('brand'=>'ABC', 'model'=>'xyz', 'size'=>13),
array('brand'=>'QWE', 'model'=>'poi', 'size'=>23),
array('brand'=>'ABC', 'model'=>'xyz', 'size'=>18),
);
$newArray = array();
foreach($sourceArray as $element) {
$elementKey = $element['brand'] . '_' . $element['model'];
if(!isset($newArray[$elementKey])) {
$newArray[$elementKey] = array('brand'=>$element['brand'],
'model'=>$element['model'],
'size'=>array($element['size']),
);
}
else {
if(!in_array($element['size'], $newArray[$elementKey]['size'])) {
$newArray[$elementKey]['size'][] = $element['size'];
}
}
}
print_r($newArray);
?>
, , . (.. .)