Re: Is this a typo or what?

From: Date: Tue, 22 May 2001 18:46:32 +0000
Subject: Re: Is this a typo or what?
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-53895@lists.php.net to get a copy of this message
----- Original Message ----- From: "Floyd Baker" <fbaker@olm1.com> To: "Henrik Hansen" <hh@mailserver.dk> Cc: "Henrik Hansen" <hh@mailserver.dk>; "PHP General List" <php-general@lists.php.net> Sent: Tuesday, May 22, 2001 8:16 PM Subject: Re: [PHP] Is this a typo or what? > On 22 May 2001 19:32:00 +0200, you wrote: > > >Floyd Baker <fbaker@olm1.com> wrote: > > > > > > > > I removed one of the two above the bottom 'return rettext'. > > > > > > >There are sure something with that script, at least I found out there > >is a } too much, maybe you removed one too many, can i see the > >original script? I would also advise you to try and ident the script > >correctly which makes it like 100% easier to read. > > > >-- > >Henrik Hansen > > > http://www.php.net/manual/en/ref.strings.php > > The top example of user contributed notes. I didn't take anything > out.. It comes that way... with 15 brackets. <g> The extra one I > think is the second (or third) one up from the bottom. > > Yes I have the whole thing indented to make sense. I am still working > on it to make it work. > > Floyd > Floyd, This works fine for me (if this is the correct example you were looking at): function wraptext($text, $wrapmargin){ $rettext = ""; $linebuf = ""; $linelen = 0; $tok = split("[ \t]", $text); $numtok = count($tok); for ($i = 0; $i < $numtok; $i++){ $elem = $tok[$i]; $elemlength = strlen($elem) + 1; if (($linelen + $elemlength) > $wrapmargin){ $rettext = $rettext . $linebuf . "<br>"; $linebuf = ""; $linelen = 0; } // Do we have a newline in this element? $pos = strrpos($elem, "\\n"); if ($pos){ $before = substr($elem, 0, $pos); $after = substr($elem, $pos); $rettext = $rettext . $linebuf . " " . $before . "<br>"; $linebuf = $after; $linelen = strlen($after); }else{ $linebuf = $linebuf . " " . $elem; $linelen = $linelen + $elemlength; } } return $rettext; } $test = wraptext("this is just a test to see if this thing works if not the fuck it.", "10"); echo"$test";

« previous php.general (#53895) next »