我有一个这样的字符串:鸿沟字符串assoc命令阵列
$config = 'app.name = "My App";
app.id = "myappid";
app.components.cache.id = "Memcache";';
我需要将其转换成数组是这样的:
app=>[
'name=>'My App',
'id'=>'myappid',
'components'=>[
'cache'=>['id'=>'Memcache']
]
]
我使用爆炸,对上个鸿沟,但我不知道接下来我需要做什么。
$arr = explode(";", $config);
$data = [];
foreach ($arr as $item) {
$pieces = explode('=', $item);
$pieces_dotes = explode('.', $pieces[0]);
foreach ($pieces_dotes as $piece) {
//what i need to do here?
}
}