Revision: 41972
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 25, 2011 14:38 by tomasdev
Initial Code
var lineSplit = function(str, lines){
lines = lines || 3;
var strArr = str.split(" "),
cropSize = Math.ceil(strArr.length / lines),
splitted = [];
while(strArr.length){
splitted.push(strArr.splice(0, cropSize).join(" "));
}
return splitted;
};
Initial URL
Initial Description
Parameters: required **[string]**, optional **[number of lines]**. By default it breaks the string passed into 3 lines. It takes a string and converts it to an array of strings, splitting the original string into smaller parts (useful for word breaking).
Initial Title
Word breaker (or how to split a string into lines)
Initial Tags
Initial Language
JavaScript