I have a string format for pushing an item into a recursive array.
Ex. CEN_SCH_SET_FUL_INT_FAS
or CEN_SCH_BUS_FUL_ACC_DIP
or CEN_SCH_BUS
What I am trying to do is, insert a specific value ex CEN_SCH_BUS
will be inserted into a multidimensional array with the keys ex. $global_array['CEN']['SCH']['BUS'] = "CEN_SCH_BUS"
and same for the other cases.
I have tried to with,
array_walk_recursive($value_toinsert , function($item, $key) {
$global_array[$key] = $value_toinsert;
});
but can't see it to work.
One example insertion of CEN_SCH_SET_FUL_TEC
, so CEN_SCH_SET_FUL_TEC is inserted at CEN > SCH > SET > FUL
Array
(
[CEN] => Array
(
[SCH] => Array
(
[SET] => Array
(
[FUL] => CEN_SCH_SET_FUL_TEC
)
)
)
)
Note: I want to keep adding the other values in the array. It can be within the existing key indexes or different (kind of a tree). Not just one value.