Javascript slice by character count
Posted: Tue Oct 04, 2011 4:04 am
How would one go about splitting up a block of text say 1000 characters long into 200 character segments and making each segment a div?
Code: Select all
string.split( seperator )
Code: Select all
$array = explode( seperator, $string );
Code: Select all
string1 = string.substr(0,200)
string2 = string.substr(200,200)
string3 = string.substr(400,200);
Code: Select all
length = string.length;
loops = (length/200)
strings = []
for( var i = 0; i < loops; i++ )
{
strings[i] = string.substr( (i*200), 200 );
}