Re: [PHP] Simple (??) control structure problem

2001-07-15 Thread Christopher Kaminski

Thanks alot! I didn't do that because I wasn't aware of the nl2br()
function.

I just taught myself php last weekend.  There's still plenty for me to
learn.

"Yz James" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi Christopher,
>
> Why not use nl2br() and trim() ?
>
> $string = trim($string); // Clear any unwanted white space (trailing and
> leading);
> $string = nl2br($string); // Add line breaks where necessary
>
> echo "$string"; // Voila
>
> James
>



-- 
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] Simple (??) control structure problem

2001-07-15 Thread James, Yz

Hi Christopher,

Why not use nl2br() and trim() ?

$string = trim($string); // Clear any unwanted white space (trailing and
leading);
$string = nl2br($string); // Add line breaks where necessary

echo "$string"; // Voila

James

"Christopher Kaminski" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm trying to write a simple weblog script, but I've encountered a
> perplexing problem.  I'm sure I'm overlooking something simple.
>
> I'm trying to take  form input, parse it, and wrap it in 
tags.
> The problem is removing extra carriage returns.  I'm sure there's a
problem
> with the "if ($sentence != ' ')", but I don't know what the right
> conditional statement is.  No matter what I put in there, it keeps
> processing any extra blank lines and putting an extra pair of ""
tags
> in.  Granted, this doesn't effect the way the page is displayed.  For
> correctness sake, I'd rather not have them in there.
>
> Here's the simple page I threw together to illustrate the problem:
>
> 
> 
>
>  if ($submit) {
>
> $funk = explode("\n", $paragraph);
> foreach ($funk as $key => $sentence) {
> if ($sentence != ' ')) {
> $funk[$key] = "" . $sentence . "\n";
> echo $funk[$key];
> }
> }
>
> } else {
> ?>
> 
> Text:
> 
> 
>  }
> ?>
>
> 
> 
>
> Thanks in advance,
> Chris
>
>



-- 
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]




[PHP] Simple (??) control structure problem

2001-07-15 Thread Christopher Kaminski

I'm trying to write a simple weblog script, but I've encountered a
perplexing problem.  I'm sure I'm overlooking something simple.

I'm trying to take  form input, parse it, and wrap it in  tags.
The problem is removing extra carriage returns.  I'm sure there's a problem
with the "if ($sentence != ' ')", but I don't know what the right
conditional statement is.  No matter what I put in there, it keeps
processing any extra blank lines and putting an extra pair of "" tags
in.  Granted, this doesn't effect the way the page is displayed.  For
correctness sake, I'd rather not have them in there.

Here's the simple page I threw together to illustrate the problem:




 $sentence) {
if ($sentence != ' ')) {
$funk[$key] = "" . $sentence . "\n";
echo $funk[$key];
}
}

} else {
?>

Text:







Thanks in advance,
Chris



-- 
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]