- reset: documentation ( source)
- print_r: documentation ( source)
- array_merge: documentation ( source)
- array_unique: documentation ( source)
- current: documentation ( source)
<?php
$configArray = array(
'grand_total' => array(
'before' => array(),
'_code' => 'grand_total',
),
'discount' => array(
'before' => array('grand_total'),
'_code' => 'discount',
),
);
reset($configArray);
$element = current($configArray);
foreach ($configArray as $code => $data) {
foreach ($data['before'] as $beforeCode) {
if (!isset($configArray[$beforeCode])) {
continue;
}
$configArray[$code]['before'] = array_unique(
array_merge(
$configArray[$code]['before'],
$configArray[$beforeCode]['before']
)
);
}
}
print_r($configArray);