例如,如何引爆一根绳子
#heavy / machine gun #test为了只得到"heavy"和"test"?
我试过爆炸,但到目前为止我只得到了"heavy / machine gun“和"test”
提前谢你,杰莱米。
发布于 2014-08-22 08:53:49
可替代爆炸的方法:
$str = "#heavy / machine gun #test";
preg_match_all('/#([^\s]+)/', $str, $matches);
var_dump($matches[1]);这将基本上找到给定字符串中的所有哈希标签。
发布于 2014-08-22 08:51:24
重新爆炸你的“第一”部份的空间,只得到‘沉重’。
$heavy = explode (' ', $my_previous_explode[1]); // I guessed you exploded on '#', so array index = 1发布于 2014-08-22 09:32:38
在这种情况下,正则表达式显然更健壮,但只是为了好玩:
$str = '#heavy / machine gun #test';
$arr = array_filter(array_map(function($str){
return strtok($str, ' ');
}, explode('#', $str)));» example
https://stackoverflow.com/questions/25443040
复制相似问题