Sim*_*son 5 php regex preg-replace
我preg_match()用来从变量中提取文本片段,让我们说变量看起来像这样:
[htmlcode]This is supposed to be displayed[/htmlcode]
middle text
[htmlcode]This is also supposed to be displayed[/htmlcode]
Run Code Online (Sandbox Code Playgroud)
我想提取[htmlcode]'s 的内容并将它们输入到数组中.我这样做是通过使用preg_match().
preg_match('/\[htmlcode\]([^\"]*)\[\/htmlcode\]/ms', $text, $matches);
foreach($matches as $value){
return $value . "<br />";
}
Run Code Online (Sandbox Code Playgroud)
上面的代码输出
[htmlcode]This is supposed to be displayed[/htmlcode]middle text[htmlcode]This is also supposed to be displayed[/htmlcode]
Run Code Online (Sandbox Code Playgroud)
代替
如果真的没有想法
| 归档时间: |
|
| 查看次数: |
93 次 |
| 最近记录: |