Re: Callin PHP gurus...figure this out

From: Date: Fri, 26 Apr 2002 10:00:10 +0000
Subject: Re: Callin PHP gurus...figure this out
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-94716@lists.php.net to get a copy of this message
forgot the " to ' conversion: // this should do the job quite fine. $var = str_replace ("\"", "'", $var); Regards Michael "Michael Virnstein" <michael.virnstein@brodos.de> schrieb im Newsbeitrag news:20020426095824.50192.qmail@pb1.pair.com... > if you want to write into the database, i wouldn't convert newline to <br>. > do this > when you read from the database using nl2br($var) ot convert every newline > in $var to <br>. > default <br> after 75 characters if no <br> was found before. > if you don't care about word-splitting, you could do the following: > > //INSERT TO DATABASE > //max number of chars per line > $maxchars = 75; > //lets say $var is the content of your textarea > $lines = explode("\n", $var); > > // text we want to write to the db > $newtext = ""; > > foreach ($lines as $line) { > if (strlen($line) > $maxchars) { > $newtext .= substr($line, 0, $maxchars)."\n"; > $newtext .= substr($line, $maxchars)."\n"; > } > } > > > // SELECT FROM DATABASE > > //lets say $var is the selected content > echo nl2br($var); > > This is very simple solution. It won't look for words and splits after the > word > and if your line is 76 chars long, it'll convert it into two lines, onw with > 75 chars > and one with 1 char. but it's a start i think. > > Regards Michael > > > > > "R" <r@jumac.com> schrieb im Newsbeitrag > news:000b01c1ed6e$d21595e0$0a6da8c0@lgwezec83s94bn... > > Greetings All, > > (Special greetings go out to Steve for excellient previous help - Thanks > > again dude) > > Calling all PHP gurus, have broked my head over this but cant seem to > figure > > this out in c,perl or java servlets. > > Am new to PHP so dont even know the common functions leave alone the > answer > > to this problem. > > Heres the setup: > > I have a form with just one TEXTAREA > > Data from this form is entered directly into the database > > > > BUT... > > > > everytime a user presses the ENTER or RETURN key on the keyboard, when the > > PHP script validates the form > > I want it to add <br> it should also add a <br> if the line is > sayyyyy....75 > > charactors long & if there is no <br> or enter key pressed.. > > If it finds any " it should convert it to ' > > > > Any ideas? > > > > Any help appreciated. > > Have a great day. > > -Ryan A. > > > >

« previous php.general (#94716) next »