$date could be "23/09/2012" or "23-09-2012" or "23\09\2012"
preg_split('/[\/\-\\]/', $date);
不知道为什么 PHP 保持抛出missing terminating ] error
?
$date could be "23/09/2012" or "23-09-2012" or "23\09\2012"
preg_split('/[\/\-\\]/', $date);
不知道为什么 PHP 保持抛出missing terminating ] error
?
preg_split('/[\/\-\\]/', $date);
^escaping the closing ']'
请改为执行以下操作,以消除歧义
preg_split('/[\/\-\\\\]/', $date);
没有必要 escape -
,但你也可以使用\-
。
代码:
$date = 'as\sad-s/p';
$slices = preg_split('/[\/\-\\\\]/', $date);
print_r($slices);
输出:
Array ( [0] => as [1] => sad [2] => s [3] => p )