By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,118 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,118 IT Pros & Developers. It's quick & easy.

How to format this? Comma and periods stuff

matheussousuke
100+
P: 249
How do I format this?

I know that
Expand|Select|Wrap|Line Numbers
  1.     $from = "From: $a2[0] <$a2[1]>";
is wrong, so should it be:
Expand|Select|Wrap|Line Numbers
  1. $from = "From: '$a2['0']'.'<$a2['1']>.'";
???
Dec 9 '11 #1
Share this Question
Share on Google+
4 Replies


100+
P: 1,059
read how to concatenate string and variable.
Dec 10 '11 #2

omerbutt
100+
P: 638
hi
try this
Expand|Select|Wrap|Line Numbers
  1. $from = "From: ".$a2[0]." <".$a2[1].">";
regards,
Omer Aslam
Dec 10 '11 #3

Dormilich
Expert Mod 5K+
P: 8,639
I don't see what's wrong with the first example. the second ain't wrong from PHP's syntax point-of-view, but certainly invalid when it comes to mail addresses.

though you might use a printf function (better readable, IMO):
Expand|Select|Wrap|Line Numbers
  1. // if $a contains only those 2 values
  2. $from = vsprintf('From: %s <%s>', $a);
  3.  
  4. // otherwise
  5. $from = sprintf('From: %s <%s>', $a[0], $a[1]);
Dec 15 '11 #4

matheussousuke
100+
P: 249
lol, the first one wasn't wrong, but I was worried cause it was too old. thx
Dec 15 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.