Home  >  Article  >  Backend Development  >  请问一个字符串分割有关问题

请问一个字符串分割有关问题

WBOY
WBOYOriginal
2016-06-13 11:10:56768browse

请教一个字符串分割问题
  我有一个字符串,内容可能包含"+", "+", "-", "-", " ", " ", ".", ".", ":", ":"这些字符,我将他们进行替换

<br />$vowels = array("+", "+", "-", "-", " ", " ", ".", ".", ":", ":");<br />$file_name = str_replace($vowels, "+", $str);<br />

结果出现了像"试题+++小赵+动漫达人组+swf"这样的字符,但我需要里面的汉字部分,请教如何进行分割,或者从一开始是否就不适用我的那个替换方式,谢谢~

php 字符串分割
------解决方案--------------------
这不是对的吗?如果你不需要+ 则 str_replace($vowels, "", $str);
还是说连swf这个也不要? 
------解决方案--------------------
$arr=preg_split('/[+]+/', $file_name);
print_r($arr);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn