我需要一些关于preg_split和我的代码的帮助。
I有输出:
FGT-603906536077 # ==测试名称:测试== Test2名称: Test2 == Test.adada名称: Test.adada == test_Test名称: test_Test ==测试名称:测试测试==测试名称:测试名称:测试-测试
我需要这样的排列:
Array {
[0] => Test
[1] => Test2
[2] => Test.adada
[3] => test_Test
[4] => test test
[5] => test-test
}我不知道如何制作数组,就像我用输出写的那样。
谢谢!
发布于 2016-12-16 10:48:32
在php中使用preg_match_all
<?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]);
?>输出将
Array {
[0] => Test
[1] => Test2
[2] => Test.adada
[3] => test_Test
[4] => test test
[5] => test-test
}https://stackoverflow.com/questions/41182629
复制相似问题