How to convert an array to an array string in php

function array2string($arr) {
$temp=[];
foreach ($arr as $key=>$value){
if(is_array($value)){
if(!empty($value)){
$temp[] = '\''.$key.'\'=>\''.array2string($value).'\'';
                                                        }
else{
$temp[]='\''.$key.'\'=>[]';
}
        }
else{
$temp[]='\''.$key.'\'=>\''.$value.'\'';
}
    }
$temp_str = implode(',', $temp);
$re='['.                                                                            $temp_str.']';
return $re;
}    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325644029&siteId=291194637