I have a problem with creating a recursive array with PHP.
I need to format this string to a multidimensional array with the dot-separated elements indicating multiple levels of array keys.
$str = "code.engine,max_int.4,user.pre.3,user.data.4";
The output for this example would be:
$str = array(
"code" => "engine",
"max_int" => 4,
"user" => array(
"pre" => 3,
"data" => 4
)
);
I will start with an explode
function, but I don't know how to sort it from there, or how to finish the foreach.