Re: Re: string function that inserts a char

From: Date: Sun, 21 Mar 2004 02:31:58 +0000
Subject: Re: Re: string function that inserts a char
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-181065@lists.php.net to get a copy of this message
"Jason Giangrande" <jason@giangrande.org> wrote in message news:405CB614.4040609@giangrande.org... > Five wrote: > > "Five" <primeooze@hotmail.com> wrote in message > > news:20040320203727.3343.qmail@pb1.pair.com... > > > >>I just finished looking through string functions > >>http://us2.php.net/manual/en/ref.strings.php > >>and can't find one that inserts a character, not replaces one. > >> > >>If there's a string that's over 50 chars long without a space, I want to > >>insert a space without replacing or losing any of the > >>original characters. Is there a function to do that? > >> > >>advance thanks, > >>Dale > > > > > > I should add that, unless there's a function that does it all, I'm not really > > concerned with the finding the 50th char part. I know > > there's other funcs for that kind of thing. It's just that all I'm trying > > to do is make sure that when the string is output, it will > > wrap to the width of a table and not stretch the table width to suit it's fancy. > > If I manufacture a function to do all of the little things necessary to make this thing > > wrap, it seems like a lot of ugly code to do > > a simple task. > > > > Use substr_replace() and set the length value to 0. Here's an example: > > $text = "Thistext"; > echo "$text<br />"; > $text = substr_replace($text, " ", 4, 0); > echo $text; > > Test it and you will see that a space is added into the text without > replacing any of it. > > -- > Jason Giangrande <jason@giangrande.org> > http://www.giangrande.org > http://www.dogsiview.com Thanks Jason

« previous php.general (#181065) next »