Scott Rowley Scott Rowley - 1 year ago 99
PHP Question

Convert PHP Array to a single Variable

What I'm trying to do is parse the CC addresses out of some mail headers using PHP, they come through as an array (oddly even if its just one address). And I'd like to just convert the array into a single long variable.

So for instance if I had the following array:

Then I want to convert that to a single variable that could be something like

I've tried several things and the main thing that I thought should have worked was the following:


foreach( $ccList as $key=>$val ){
$ccAddress .= $val.",";
Sys::log(LOG_ALERT,'CC Address is..'.$ccAddress);

but when I get that logfile it says "CC Address is...Array,"

Is there any way to accomplish what I'm wanting? I should note that as its CC addresses I won't always know if its 0 addresses or several or anywhere in between.

I've also tried a few things with print_r and var_dump but they didn't return the results I expected to see (email addresses). I think var_dump still showed "Array" (or nothing) and print_r just said "CC Address is ...1".

Any help is appreciated.

Answer Source take a look here.

$newccAddress = implode(",", $ccAddress);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download