php-general Digest 13 Jul 2011 21:03:53 -0000 Issue 7400
Topics (messages 314032 through 314041):
Re: str_replace around a character??
314032 by: Jay Ess
314033 by: Vitalii Demianets
314034 by: Jay Ess
314035 by: Shiplu Mokaddim
314039 by: Shawn McKenzie
314040 by: Florian Lemaitre
314041 by: Karl DeSaulniers
Re: Serveside Printing w/ PHP
314036 by: Marc Guay
314037 by: Marc Guay
314038 by: Marc Guay
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 2011-07-13 09:54, Karl DeSaulniers wrote:
$cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
ema...@domain.com, "
$cc = trim($cc,",");
$result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);
--- End Message ---
--- Begin Message ---
On Wednesday 13 July 2011 11:09:45 Jay Ess wrote:
> On 2011-07-13 09:54, Karl DeSaulniers wrote:
> > $cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
> > ema...@domain.com, "
>
> $cc = trim($cc,",");
> $result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);
The solution is broken because of:
1) you have missed spaces after comma in two places. It should be like this:
$cc = trim($cc,", "); // <- here space after comma in the second argument
$result = preg_replace('/(\s?)(,)(\s?)/i', ', ', $cc); // <-- the same, here
space after comma in replacement string.
2) it doesn't work with address lines like this:
To: "Some strange ,, person name" <strper...@example.com>
--
Vitalii
--- End Message ---
--- Begin Message ---
On 2011-07-13 10:36, Vitalii Demianets wrote:
On Wednesday 13 July 2011 11:09:45 Jay Ess wrote:
On 2011-07-13 09:54, Karl DeSaulniers wrote:
$cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
ema...@domain.com, "
$cc = trim($cc,",");
$result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);
The solution is broken because of:
1) you have missed spaces after comma in two places. It should be like this:
$cc = trim($cc,", "); //<- here space after comma in the second argument
$result = preg_replace('/(\s?)(,)(\s?)/i', ', ', $cc); //<-- the same, here
space after comma in replacement string.
Yes, that was pretty sloppy of me hehe.
2) it doesn't work with address lines like this:
To: "Some strange ,, person name"<strper...@example.com>
That was never the requirement ;)
--- End Message ---
--- Begin Message ---
If you are looking for a one liner reg ex, it may take some time. This may
lead wasting your development time. Better you do the following,
1. replace the string with tokens in address.
2. Split using comma.
3. Apply common email regex.
4. Replace tokens with actual strings.
5. Rebuild/join the string with ", "
With this approach you can validate individual emails too.
Sent from a handheld device
--- End Message ---
--- Begin Message ---
On 07/13/2011 02:54 AM, Karl DeSaulniers wrote:
> Hello All,
> I am needing some assistance. I am trying to add some Cc and Bcc to a
> mail script I have.
> On the form I have instructions for each to be separated by a comma + a
> space.
> In an all perfect world each user would do this perfectly. ...but since
> were working with something different,
> how can I check for this? and catch any that dont do this perfectly?
>
> Is there a reg exp that covers this? I have seen many, but some make the
> head cramp. Mi mui novicio.
> To wrap it up, I am basically trying to do this...
>
> $cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
> ema...@domain.com, "
>
> to be
>
> $cc = "ema...@domain.com, ema...@doamin.com, ema...@domain.com,
> ema...@domain.com"
>
> Any pointers would be much appreciated.
> TIA
> Best Regards,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
$cc = implode(', ', array_filter(array_map('trim', explode(',', $cc))));
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
Le 13/07/2011 16:59, Shawn McKenzie a écrit :
On 07/13/2011 02:54 AM, Karl DeSaulniers wrote:
Hello All,
I am needing some assistance. I am trying to add some Cc and Bcc to a
mail script I have.
On the form I have instructions for each to be separated by a comma + a
space.
In an all perfect world each user would do this perfectly. ...but since
were working with something different,
how can I check for this? and catch any that dont do this perfectly?
Is there a reg exp that covers this? I have seen many, but some make the
head cramp. Mi mui novicio.
To wrap it up, I am basically trying to do this...
$cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
ema...@domain.com, "
to be
$cc = "ema...@domain.com, ema...@doamin.com, ema...@domain.com,
ema...@domain.com"
Any pointers would be much appreciated.
TIA
Best Regards,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
$cc = implode(', ', array_filter(array_map('trim', explode(',', $cc))));
This should work just fine ;).
$cc = implode(', ', array_filter(filter_var_array(array_map('trim',
explode(',', $cc)), FILTER_VALIDATE_EMAIL)));
--- End Message ---
--- Begin Message ---
On Jul 13, 2011, at 9:59 AM, Shawn McKenzie wrote:
On 07/13/2011 02:54 AM, Karl DeSaulniers wrote:
Hello All,
I am needing some assistance. I am trying to add some Cc and Bcc to a
mail script I have.
On the form I have instructions for each to be separated by a
comma + a
space.
In an all perfect world each user would do this perfectly. ...but
since
were working with something different,
how can I check for this? and catch any that dont do this perfectly?
Is there a reg exp that covers this? I have seen many, but some
make the
head cramp. Mi mui novicio.
To wrap it up, I am basically trying to do this...
$cc = "ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
ema...@domain.com, "
to be
$cc = "ema...@domain.com, ema...@doamin.com, ema...@domain.com,
ema...@domain.com"
Any pointers would be much appreciated.
TIA
Best Regards,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
$cc = implode(', ', array_filter(array_map('trim', explode(',',
$cc))));
--
Thanks!
-Shawn
http://www.spidean.com
Thanks Shawn,
I had actually found the same thing myself..
$subCc = array_map('trim',explode(",",$subCc));
But I could not find my post last night to make a new comment about it.
Thank you for yours though.. I did not think of the implode part.
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--- End Message ---
--- Begin Message ---
> What type of file are you trying to print?
HTML.
--- End Message ---
--- Begin Message ---
> What type of file are you trying to print? I'm not very familiar with
> Microsoft Windows but I know a little about it. Have you considered Windows
> Powershell? Unfortunately you would essentially have to write a powershell
> script and use the PHP exec functions. Windows 7 shipped with PowerShell
> 2.0.
Hi Wayne,
Thanks for this tip, I just printed a document from the PowerShell 2.0
command line; I think this might be the path to take.
Marc
--- End Message ---
--- Begin Message ---
>> What type of file are you trying to print? I'm not very familiar with
>> Microsoft Windows but I know a little about it. Have you considered Windows
>> Powershell? Unfortunately you would essentially have to write a powershell
>> script and use the PHP exec functions. Windows 7 shipped with PowerShell
>> 2.0.
It actually is starting to look like in order to print HTML using this
method I'd have to instantiate a COM object in the shell, which I
could just do directly with PHP's built-in COM stuff.
--- End Message ---