A length defined as a parameter in the function?
Stephen,
What function returns a new line if a string reaches
Moderator: General Moderators
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
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?
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?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
lol ohhh right! I was going to sayThe Ninja Space Goat wrote:http://us2.php.net/wordwrap
Code: Select all
function foo($string, $length) {
if (strlen($string) >= $length) {
return "\n";
}
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia