Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中获取介于[]和[/“tag”之间的文本_Php_Regex_Preg Match All - Fatal编程技术网

在php中获取介于[]和[/“tag”之间的文本

在php中获取介于[]和[/“tag”之间的文本,php,regex,preg-match-all,Php,Regex,Preg Match All,我有以下脚本: [h1]tekst in header[/h1] [page] [p]text here[p] [table] [p]http://sitename.nl/file.php?get=[nickname][/p] [/table] [/page] 现在我想得到这个结果: Array ( [0] => [h1] [1] => tekst in header

我有以下脚本:

[h1]tekst in header[/h1]
[page]
    [p]text here[p]
    [table]
        [p]http://sitename.nl/file.php?get=[nickname][/p]
    [/table]
[/page]
现在我想得到这个结果:

Array
        (
            [0] => [h1]
            [1] => tekst in header
            [2] => [/h1]
            [3] => [page]
            [4] => Array (.....)
            [5] => [/page]
        )
我想不出怎么做。 我尝试了几个preg_match_all选项,但我对正则表达式没有经验


感谢您的帮助。

第一个脚本和第二个脚本之间有什么联系?奇怪的是,您给出的示例看起来像是有效的XML标记,除了[昵称]。您能用>替换[和]并使用SimpleXML吗?或者您真的需要像您正在寻找的那样将其解析为数组吗?您基本上使用的是自定义html类型的语言,正则表达式不适用于此: