-2

$string= 2013-01-0112:00:002013-01-0212:00:002013-01-0312:00:00

我想得到

$nexstring= 2013-01-0112:00:00,2013-01-0212:00:00,2013-01-0312:00:00//comma each 18 chars
4

3 回答 3

1

使用str_split

$chunks = str_split($string, 18);

$nexstring = join(',', $chunks);
于 2013-11-13T13:17:32.170 回答
1
$nextString = implode(
    ',',
    str_split($string, 18)
);
于 2013-11-13T13:17:37.473 回答
1

我认为您可以使用自动换行功能,而不是拆分字符串。

$nexstring = wordwrap($nexstring, 18, ',', true);
于 2013-11-13T13:21:51.633 回答