$thisdate = '2011-01-18 14:52:33';
$security = preg_replace('/[^\d\s]/', '', $thisdate);
echo $security;
這導致20110118 145233php preg_replace問題..如何擺脫空間?
我將如何擺脫空間的?
謝謝。
$thisdate = '2011-01-18 14:52:33';
$security = preg_replace('/[^\d\s]/', '', $thisdate);
echo $security;
這導致20110118 145233php preg_replace問題..如何擺脫空間?
我將如何擺脫空間的?
謝謝。
您正則表達式匹配的一切,是不是(^
)數字(\d
)或空間(\s
)
因此,如果您刪除的\s
preg_replace('/[^\d]/', '', $thisdate);
將取代除數字以外的所有內容
感謝您的解釋。很有幫助。 – John