I'm trying to break/split a continues series of characters in a php string at a specific point e.g.
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
to
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA开发者_开发技巧
PHP has a function called chunk_split()
which does exactly what you ask...
$myLongString = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
$splitString = chunk_split($myLongString, 20);
echo $splitString;
/*
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
*/
I would use wordwrap() with the $break parameter as " ".
Just take a look at substr
function here..
eg:
substr('foobar', 0, 3). ' ';
yields
'foo '
精彩评论