Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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 如何分解具有多个正弦的字符串_Php_String_Output_Explode - Fatal编程技术网

Php 如何分解具有多个正弦的字符串

Php 如何分解具有多个正弦的字符串,php,string,output,explode,Php,String,Output,Explode,我有一个字符串,比如: $text = 'abc,xyz,wap+web+fbortworme'; 在我的成就中,我希望能够爆炸+或者,在字符串行中,我的预期输出如示例所示: abc<br/> xyz<br/> wap<br/> web<br/> fb<br/> tw<br/> me<br/> 但是我没有得到任何输出,请看这里 非常感谢您对我的解决方案的影响您可以使用preg\

我有一个字符串,比如:

  $text = 'abc,xyz,wap+web+fbortworme';
在我的成就中,我希望能够爆炸+或者,在字符串行中,我的预期输出如示例所示:

  abc<br/>
  xyz<br/>
  wap<br/>
  web<br/>
  fb<br/>
  tw<br/>
  me<br/>
但是我没有得到任何输出,请看这里


非常感谢您对我的解决方案的影响

您可以使用
preg\u split
函数来做您想做的事情

$text = 'abc,xyz,wap+web+fbortworme';
$splitted = preg_split('/[(or),\+]/', $text);
$splitted = array_filter($splitted); // remove any empty string

print_r($splitted);
这将输出

Array
(
    [0] => abc
    [1] => xyz
    [2] => wap
    [3] => web
    [4] => fb
    [6] => tw
    [8] => me
)
这就是您的预期输出

的可能重复
Array
(
    [0] => abc
    [1] => xyz
    [2] => wap
    [3] => web
    [4] => fb
    [6] => tw
    [8] => me
)