[PHP] Re: str_replace around a character??

2011-07-14 Thread Shawn McKenzie
On 07/13/2011 04:03 PM, Karl DeSaulniers wrote:
> 
> 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
> 

You probably want the array_filter() in there also, because commas at
the beginning or end or other issues can leave you with empty array
elements that will still be imploded resulting in just a comma.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: str_replace around a character??

2011-07-13 Thread Karl DeSaulniers


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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: str_replace around a character??

2011-07-13 Thread Florian Lemaitre

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)));



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: str_replace around a character??

2011-07-13 Thread Shawn McKenzie
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php