Page 1 of 1
What function returns a new line if a string reaches
Posted: Wed Nov 08, 2006 1:33 pm
by impulse()
A length defined as a parameter in the function?
Stephen,
Posted: Wed Nov 08, 2006 1:36 pm
by Luke

what?
Posted: Wed Nov 08, 2006 1:41 pm
by impulse()
I'm sure I came across a function a couple of weeks back that takes in a string and it inserts a "\n" character at specified points within the string.
For example
"If this was the string I wanted to use but I wanted PHP to return a new line every 20 characters into the string I could use the function to that just that.
So it would look like:
"If this was the stri
ng I wanted to use b
"
Etc etc.
Maybe I was dreaming about such function?

Posted: Wed Nov 08, 2006 1:46 pm
by Luke
Posted: Wed Nov 08, 2006 2:00 pm
by Ollie Saunders
lol ohhh right! I was going to say
Code: Select all
function foo($string, $length) {
if (strlen($string) >= $length) {
return "\n";
}
}
Posted: Wed Nov 08, 2006 3:04 pm
by Chris Corbyn
Or chunk_split() if you need to split after X chars rather than at word boundaries.