0

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
user2959620
  • 29
  • 1
  • 2
  • 6
  • It's very hard to understand your problem. Can you make a more clear description of your problem? –  Nov 12 '13 at 20:57
  • This is a better solution to your problem: http://stackoverflow.com/questions/1792950/explode-string-by-one-or-more-spaces-or-tabs – ficuscr Nov 12 '13 at 20:59
  • `str_replace(' ', '', $k)` - http://php.net/manual/en/function.str-replace.php – scrowler Nov 12 '13 at 21:02

2 Answers2

0

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
Daryl Gill
  • 5,464
  • 9
  • 36
  • 69
0

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...

Community
  • 1
  • 1
Prashank
  • 796
  • 6
  • 12