Ok, so instead of an array of arrays of strings, you need an array of ojects.
In this case, you need to do something like the following:
foreach ($values as $key => $value) {
$name = $slugify->slugify($value->getColonne()->getName());
if (!isset($array[$value->getPosition()])) {
$array[$value->getPosition()] = new stdClass();
}
$array[$value->getPosition()]->$name = $value->getValue();
}
NOTE
In PHP >= 5.3 strict mode, if you need to create a property inside an object, without generating an error, instead of:
$foo = new StdClass();
$foo->bar = '1234';
You need to create the property as a position in an associative array, and then cast the array back to an object. You'd do something like:
$foo = array('bar' => '1234');
$foo = (object)$foo;
So, in that case your code will need to like like this:
foreach ($values as $key => $value) {
$name = $slugify->slugify($value->getColonne()->getName());
// cast the object as an array to create the new property,
// or create a new array if empty
if (isset($array[$value->getPosition()])) {
$array[$value->getPosition()] = (array)$array[$value->getPosition()];
} else {
$array[$value->getPosition()] = array();
}
// create the new position
$array[$value->getPosition()][$name] = $value->getValue();
// now simply cast the array back into an object :)
$array[$value->getPosition()] = (object)$array[$value->getPosition()];
}