由于工作需要,自己在手册给定的示例函数基础上改写出了这样一个函数,代码如下:
//将多维数组中所有的数值转换成字符串————》最多支持三维数组
function implodex( $glue, $array, $separator='' ) {
if ( ! is_array( $array ) ) return $array;
$string = array();
$count = 0;
foreach ( $array as $key => $val ) {
if ( is_array( $val ) )
$val = implode( $glue, $val );
if($count == 0){
$string[] = "{$val}";
}else{
$string[] = "{$glue}{$val}";
}
}
if(empty($separator))$separator = $glue;
return implode( $separator, $string );
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn