PHP preg_split到nice数组

时间:2016-12-16 10:44:10

标签: php arrays preg-split

我需要一些preg_split和我的代码的帮助。

我有输出:

  

FGT-603906536077#== [测试]名称:测试== [测试2]名称:测试2 ==   [Test.adada]名称:Test.adada == [test_Test] name:test_Test == [   test test] test:test test == [test-test] name:test-test

我需要像:

这样的数组
Array {
 [0] => Test 
 [1] => Test2 
 [2] => Test.adada
 [3] => test_Test
 [4] => test test
 [5] => test-test
}

我不知道make array是如何用我的输出写的。

谢谢!

1 个答案:

答案 0 :(得分:0)

在php中使用preg_match_all

<h:outputScript>

输出

<?php
    $your_string = "FGT-603906536077 # == [ Test ] name: Test == [ Test2 ] name: Test2 == [ Test.adada ] name: Test.adada == [ test_Test ] name: test_Test == [ test test ] name: test test == [ test-test ] name: test-test";
    preg_match_all('/\[(.*?)\]/', $your_string, $out);
    echo "<pre>";print_r($out[1]);    
?>