$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);
有没有必要逃避-
但你可以使用\-
为好。
码:
$date = 'as\sad-s/p';
$slices = preg_split('/[\/\-\\\\]/', $date);
print_r($slices);
输出:
Array ( [0] => as [1] => sad [2] => s [3] => p )