I have a problem in converting multi-dimensional array to flat array I have an input array like this:
Array
(
[0] => Array
(
[type] => MagentoCatalogRuleModelRuleConditionCombine
[aggregator] => all
[conditions] => Array
(
[0] => Array
(
[type] => MagentoCatalogRuleModelRuleConditionProduct
[attribute] => category_ids
)
)
)
[1] => Array
(
[type] => MagentoCatalogRuleModelRuleConditionProduct
[attribute] => category_ids
)
[2] => Array
(
[type] => MagentoCatalogRuleModelRuleConditionProduct
[attribute] => attribute_set_id
)
)
and I want the output is an array like this, the child array will be flattened as parent array level and it will be recognized by the index:
Array
(
[1--1] => Array
(
[type] => Magento\CatalogRule\Model\Rule\Condition\Combine
[aggregator] => all
)
[1--1--1] => Array
(
[type] => Magento\CatalogRule\Model\Rule\Condition\Product
[attribute] => category_ids
)
[1--2] => Array
(
[type] => Magento\CatalogRule\Model\Rule\Condition\Product
[attribute] => category_ids
)
[1--3] => Array
(
[type] => Magento\CatalogRule\Model\Rule\Condition\Product
[attribute] => attribute_set_id
)
)
the input array may contain many child layers and the output array must be index in that format. I'm stucking to write this logic into code. Thank you!