I'm gathering emails from a text area like so:
email1@server.com
email2@server.com
email3@server.com
When I try to print it out on the next page or split()
them nothing happends, and they come out like:
email1@server.com email2@server.com email3@server.com
What should I do?
Here is the code:
<?php
$leadmail_email_addresses2 = nl2br($leadmail_email_addresses);
$email_c = 0;
$emails_html = split("\r\n", $leadmail_email_addresses);
$email_c = count($emails_html);
?>
<?php echo($email_c); ?>
<?php echo($leadmail_email_addresses3); ?>
Text Area Line Break Problem
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
-
daveheinzel
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 02, 2003 10:47 pm
I had this same problem tonight, and I somewhere I found this nifty little thing:
nl2br()
When info is entered into my database using PHP, I don't treat line breaks. But when that data is retreived, nl2br() adds an html <br /> before the line break, reformatting the text to as it was entered.
I used it like this:
after you get your query results, do something like this:
echo nl2br("$results['emailaddresses']");
It worked for me, and I don't know much about PHP, so I'm sorry I can't elaborate.
nl2br()
When info is entered into my database using PHP, I don't treat line breaks. But when that data is retreived, nl2br() adds an html <br /> before the line break, reformatting the text to as it was entered.
I used it like this:
after you get your query results, do something like this:
echo nl2br("$results['emailaddresses']");
It worked for me, and I don't know much about PHP, so I'm sorry I can't elaborate.
The problem is simple as is the solution:
[edit of a typo --JAM
]
Code: Select all
<?php
# Re-Format the new lines to standard unix format
$leadmail_email_addresses = ereg_replace("\r\n","\n",$leadmail_email_addresses);
# Create an Array of the emails
$emails_html = split("\n",$leadmail_email_addresses);
$email_c = count($emails_html);
echo $email_c;
echo nl2br($leadmail_email_addresses);
# Or
echo join('<br />', emails_html);
?>- mrvanjohnson
- Forum Contributor
- Posts: 137
- Joined: Wed May 28, 2003 11:38 am
- Location: San Diego, CA
I think mchaggis meant to say
not
Code: Select all
<?php
echo nl2br($leadmail_email_addresses);
?>Code: Select all
<?php
echo nr2br($leadmail_email_addresses);
?>