简体   繁体   中英

Assign array values to PHP variable

I have some code which checks to see whether a certain variable is an array. If it is, I would like to assign all the array values to a single, comma-separated PHP variable. Here is the code:

if (is_array($value)) {         
    //Need to assign the array variables to the PHP variable $files, but how?
    $postdata.=$files;          
} else {
    $postdata.=$value;
}  

I have tried to use $files = print_r(array_values($value)); but it does not seem to work for me. What am I doing wrong? Thanks.

尝试:

$string = implode(',', $array);

添加以下行: $files= implode(',', $value);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM