Re: [PHP] Is this a typo or what?

2001-05-22 Thread Henrik Hansen

Floyd Baker [EMAIL PROTECTED] 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-22 Thread Floyd Baker

On 22 May 2001 19:32:00 +0200, you wrote:

Floyd Baker [EMAIL PROTECTED] 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

--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-22 Thread Charles Williams \(CEO\)


- Original Message -
From: Floyd Baker [EMAIL PROTECTED]
To: Henrik Hansen [EMAIL PROTECTED]
Cc: Henrik Hansen [EMAIL PROTECTED]; PHP General List
[EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-21 Thread Henrik Hansen

Floyd Baker [EMAIL PROTECTED] wrote:

  There's an extra '}' in the first example for a word wrap function,
  under string functions in the manual..
  
  I think I removed the right one but I'm still having trouble with it.
  Can someone else take a crack at it too?  
  

I dont see any extra } what i see is:

$text = The quick brown fox jumped over the lazy dog.;
$newtext = wordwrap( $text, 20 );

echo $newtext\n;

a note for wordwrap is if you use if for wrapping in html you might
want to do something like this, to split every line with a br:

wordwrap($text, 20, br);

-- 
Henrik Hansen


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-21 Thread Floyd Baker

On 21 May 2001 23:22:17 +0200, you wrote:

Floyd Baker [EMAIL PROTECTED] wrote:

  There's an extra '}' in the first example for a word wrap function,
  under string functions in the manual..
  
  I think I removed the right one but I'm still having trouble with it.
  Can someone else take a crack at it too?  
  

I dont see any extra } what i see is:

$text = The quick brown fox jumped over the lazy dog.;
$newtext = wordwrap( $text, 20 );

echo $newtext\n;

a note for wordwrap is if you use if for wrapping in html you might
want to do something like this, to split every line with a br:

wordwrap($text, 20, br);

-- 
Henrik Hansen



Henrik

You are looking in the wrong area..  I'm working with php3.  

 There's an extra '}' in the first example for a word wrap function,
 under string functions in the manual..

Here is what I see... and if you count the brackets, there are 15.. ?

[EMAIL PROTECTED]
12-Nov-1999 05:15 
A quick and dirty function to wrap text at a given wrap margin: 

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 . \n; 
$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 . \n; 
$linebuf = $after; 
$linelen = strlen($after); 
} 
else 
{ 
$linebuf = $linebuf .   . $elem; 
$linelen = $linelen + $elemlength; 
} 
} 

// 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 . \n; 
$linebuf = $after; 
$linelen = strlen($after); 
} 
else 
{ 
$linebuf = $linebuf .   . $elem; 
$linelen = $linelen + $elemlength; 
} 
} 
return $rettext; 
} 

 


--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-21 Thread Henrik Hansen

Floyd Baker [EMAIL PROTECTED] wrote:

  Henrik
  
  You are looking in the wrong area..  I'm working with php3.  
  
   There's an extra '}' in the first example for a word wrap function,
   under string functions in the manual..
  
  Here is what I see... and if you count the brackets, there are 15.. ?
  

ok well, I can see the script inserts \n, if you are wrapping in html
you dont see the text is actual wraping because you need to add br
instead, maybe do a nl2br() on the ourput from the functions and see
if the text wraps as wanted.

-- 
Henrik Hansen


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a typo or what?

2001-05-21 Thread Floyd Baker

On 22 May 2001 00:19:41 +0200, you wrote:

Floyd Baker [EMAIL PROTECTED] wrote:

  Henrik
  
  You are looking in the wrong area..  I'm working with php3.  
  
   There's an extra '}' in the first example for a word wrap function,
   under string functions in the manual..
  
  Here is what I see... and if you count the brackets, there are 15.. ?
  

ok well, I can see the script inserts \n, if you are wrapping in html
you dont see the text is actual wraping because you need to add br
instead, maybe do a nl2br() on the ourput from the functions and see
if the text wraps as wanted.

-- 
Henrik Hansen

Well there are no br's in the field to convert. 

The ascii between the ;'s is exactly this... One long line.

;I\'ll add details later.  Now is the time for all good men to come to
the aid of their country...  The quick brown fox jumped over the lazy
dogs back 12345 times...  Of all the fishes in the sea, the mermaid is
still the only one for me;

So this routine with the bracket should work to insert the slashes but
I've removed the extra (correct?) bracket and it does not work..  ?

I removed one of the two above the bottom 'return rettext'.   

Floyd

--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]