explode()一个字符串。 脱掉空白[关闭]

I need to explode $k like this

$kExploded = explode(" ", $k);

Now if it ca be useful I also add that

var_dump($k)= string(20) "2013-01-01 12:00:00 " string(20) "2013-01-02 12:00:00 " 
               string(20) "2013-01-03 12:00:00 " 

How to explode $K?

if I echo out $k returns this

2013-01-01 12:00:00 2013-01-02 12:00:00 2013-01-03 12:00:00

I just would like to get this:

2013-01-0112:00:002013-01-0212:00:002013-01-0312:00:00//take off all white space

It has been answered many times on Stackoverflow, perhaps you should have researched first, but this should solve the problem:

preg_replace('/\s+/', '', $k);

already answered

How to strip all spaces out of a string in php?

Remove excess whitespace from within a string

and maybe many more places...

Why not use str_replace to remove all white spaces?

$k = "2013-01-01 12:00:00 2013-01-02 12:00:00 2013-01-03 12:00:00";
$k = str_replace(" ","",$k); // Replace white space, with no space in $k
echo $k; // 2013-01-0112:00:002013-01-0212:00:002013-01-0312:00:00