我正在尝试构建一个解析器,该解析器应该将文本缩进(TAB KEY)转换为多级 php 数组(我对编程很陌生)
我有一个使用这种格式编写的 txt 文件:
test1
test2
blah3
blah4
blah5
more content
some more
and more content
解析后它应该返回一个数组,如:
$myarray[0]['c'] = "test1";
$myarray[0]['s'][0]['c'] = "test2";
$myarray[0]['s'][0]['s'][0]['c'] = "blah3";
$myarray[0]['s'][1]['c'] = "blah4";
$myarray[0]['s'][2]['c'] = "blah5";
$myarray[0]['s'][2]['s'][0]['c'] = "more content";
$myarray[1]['c'] = "some more";
$myarray[1]['s'][0]['c'] = "and more content";
可以在php中构建这样的功能吗?
在你问我不能使用 xml 之前,因为我已经有了必须先转换为 xml 的 txt 文件
非常感谢您的回答