php数组转php代码,php数组转php字符串
function dd_array2str($array,$lv=1){ if(is_array($array)){ $str = ‘[‘."\n"; foreach($array AS $key=>$value) { $str .= str_repeat(‘ ‘,$lv).‘\‘‘.$key.‘\‘=>‘.dd_array2str($value,$lv+1).‘,‘."\n"; } $str = substr($str,0,strlen($str)-2); $str .= "\n".str_repeat(‘ ‘,$lv-1).‘]‘; if($lv == 1) $str .= ‘;‘; return $str; }else{ $array = addslashes($array); return ‘\‘‘.$array.‘\‘‘; } }
已经做了单引号的转义
支持多维数组
相关推荐
清风徐来水波不兴 2019-12-30
aaLiweipeng 2019-09-02
贝伦酱 2009-11-25
itkissit 2009-11-16
weixuejunphp 2014-02-17
PHP100 2019-03-28
PHP100 2019-03-27
PHP100 2019-03-27