首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >preg_split到nice数组

preg_split到nice数组
EN

Stack Overflow用户
提问于 2016-12-16 10:44:10
回答 1查看 152关注 0票数 0

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

I有输出:

FGT-603906536077 # ==测试名称:测试== Test2名称: Test2 == Test.adada名称: Test.adada == test_Test名称: test_Test ==测试名称:测试测试==测试名称:测试名称:测试-测试

我需要这样的排列:

代码语言:javascript
复制
Array {
 [0] => Test 
 [1] => Test2 
 [2] => Test.adada
 [3] => test_Test
 [4] => test test
 [5] => test-test
}

我不知道如何制作数组,就像我用输出写的那样。

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-16 10:48:32

在php中使用preg_match_all

代码语言:javascript
复制
<?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]);    
?>

输出将

代码语言:javascript
复制
Array {
 [0] => Test 
 [1] => Test2 
 [2] => Test.adada
 [3] => test_Test
 [4] => test test
 [5] => test-test
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41182629

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档