Jump to content

Help required formatting output string


barryc

Recommended Posts

Hi All,

I need some help please with formatting output such that it appears inline (eg Arrival Date: 15 May 2007) rather than the existing three line output when sent via email. Thanks,  Barry



***Output form***

$arrival_day = $_POST['select1'] ;
$arrival_month = $_POST['select2'] ;
$arrival_year = $_POST['select3'] ;
...

"Arrival Date: $select1\n" .
"Arrival Month: $select2\n" .
"Arrival Year: $select3\n" .
...
Link to comment
https://forums.phpfreaks.com/topic/28294-help-required-formatting-output-string/
Share on other sites

you can use the string concatenation operator "." which returns the concatenation

Example:
$arrival = $_POST['select1']." ".$_POST['select2']." ".$_POST['select3'] ;

More detail about String Operators
[url=http://www.phpfreaks.com/phpmanual/page/language.operators.string.html]http://www.phpfreaks.com/phpmanual/page/language.operators.string.html[/url]
[code]
$arrival_day = $_POST['select1'] ;
$arrival_month = $_POST['select2'] ;
$arrival_year = $_POST['select3'] ;

echo "Arrival Date: $select1 $select2 $select3";
[/code]

yea?  or if you need it to output 1 way to a page or format it to 1 line for email, just use if statements or whatever floats your boat.
Wow!!  Very imprressed with the speed of response to my question. Thank you both very much indeed for your input. I had looked under PHP String Operators but was expecting to see concatenation, and I had tried a variation of the second option (with and without commas!) but did not appreciate the use of the echo command. Very helpful guys, thanks again. Kind Regards, Barry

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.