Multi-line string?
Moderator: General Moderators
Multi-line string?
Quick question..
I'm trying to format an email body in PHP with variables. But the here document method I'm using is not working. Bascially I want an output similar to this:
Name: $name
email: $email
...
...
Yet, I can't get the carriage returns to output properly. What's the best way to do this? I keep getting parse errors with the here document method..
Any ideas?
Thanks!
I'm trying to format an email body in PHP with variables. But the here document method I'm using is not working. Bascially I want an output similar to this:
Name: $name
email: $email
...
...
Yet, I can't get the carriage returns to output properly. What's the best way to do this? I keep getting parse errors with the here document method..
Any ideas?
Thanks!
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Code: Select all
$string = "something
something
something";
$string = "something\nsomething\nsomething";Text Box Formatting...
I have a related question.
In HTML normally we have a text box only. In thetext box, the user may be typing with indents, line breaks etc.
How can they be captured and stored.
I need to do this and then display them.
As an analogy, in this post i left a line gap, how can this be captured?
Also, if i want to give the user the option of formatting like, bold, italics etc. How can i do it?
Any pointers soembody can gice?
In HTML normally we have a text box only. In thetext box, the user may be typing with indents, line breaks etc.
How can they be captured and stored.
I need to do this and then display them.
As an analogy, in this post i left a line gap, how can this be captured?
Also, if i want to give the user the option of formatting like, bold, italics etc. How can i do it?
Any pointers soembody can gice?
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
or you can do the perl method:
just make sure that end or whatever you decide to use starts at the beginning of its own line.
Code: Select all
print <<<END
something
something
something
END;- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
Code: Select all
<?php
str_replace("\n","",$data);
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Who wanted a function to remove linebreaks?Takuma wrote:Code: Select all
<?php str_replace("\n","",$data); ?>
Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Text Box Formatting...
This kind of formatting will automatically be stored as linebreaks (\n) or tabs (\t) and if you want them to display as entered you can put it within <pre> tags.rlogin wrote:In thetext box, the user may be typing with indents, line breaks etc.
How can they be captured and stored.
I need to do this and then display them.
Code: Select all
<pre>
any s p a c e s and
line
breaks will be displayed</pre>Allow them to use HTML or have something like the BBCode that this forum uses.rlogin wrote:Also, if i want to give the user the option of formatting like, bold, italics etc. How can i do it?
Mac