robvr6
December 7, 2012, 5:50pm
1
This will be a very simple questionfor the experts Im new to php but I have a form and its sending fine but I need to put a space in btween each line Im presuming the spacing will go between each of the lines below
$body.='Wedding Date: '.$date."\
";
$body.='Time Of Service: '.$time."\
";
$body.='Brides Name: '.$bname."\
";
$body.='Brides Phone: '.$bphone."\
";
$body.='Grooms Name: '.$gname."\
";
Thanks
ALEX__
December 7, 2012, 8:28pm
2
If by ‘space’ you mean a blank line between lines in your email, then use two new line characters "
" instead of one, like so:
$body.='Wedding Date: '.$date."\
\
";
robvr6
December 7, 2012, 8:46pm
3
Thats brilliant exactly wht I meant - thanks very much for taking the time to help - one more thing is it easy to print out something like
underneath certain things to separate the form into sections so to speak?
Thanks
Rob
ALEX__
December 8, 2012, 10:27am
4
Yes, you can just do something like:
$body .= 'Wedding Date' . "\
";
$body .= '-------------' . "\
";
$body .= $date . "\
\
";
If you have many fields to format in this way I’d put the code into a function so you don’t have to change multiple lines if you want to change the format of the email, such as:
function formatEmailField($field, $value) {
return $field . "\
"
. '-------------' . "\
"
. $value . "\
\
";
}
rpkamp
December 8, 2012, 10:39am
5
If you want the line to be always exactly as long as the text it’s under you can use:
function formatEmailField($field, $value)
{
return $field."\
"
. str_repeat('-', strlen($field))."\
"
. $value."\
\
";
}