Compilation failed: missing terminating ] for character class

风流意气都作罢 提交于 2019-11-30 14:43:43
preg_split('/[\/\-\\]/', $date);
                   ^escaping the closing ']' 

Do the following instead, to remove ambiguity

preg_split('/[\/\-\\\\]/', $date);

There is no need to escape -, but you could use \- as well.


Code:

$date = 'as\sad-s/p';
$slices =  preg_split('/[\/\-\\\\]/', $date);
print_r($slices);

Output:

Array ( [0] => as [1] => sad [2] => s [3] => p )
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!