$thisdate = '2011-01-18 14:52:33';
$security = preg_replace('/[^\d\s]/', '', $thisdate);
echo $security;
This results in 20110118 145233
How would i get rid of the space?
Thanks.
$thisdate = '2011-01-18 14:52:33';
$security = preg_replace('/[^\d\s]/', '', $thisdate);
echo $security;
This results in 20110118 145233
How would i get rid of the space?
Thanks.
your regex matches everything that is not(^
) digit(\d
) or space(\s
)
so if you remove the \s
preg_replace('/[^\d]/', '', $thisdate);
will replace everything except digits