PHP 多维数组处理,将1维或者多维数组处理成字符串
时间:2011-03-07 来源:无量小猪
function arraycd($arr){
static $res_arr=array();
if(is_array($arr))
{
foreach($arr as $key=>$val)
{
if(is_array($val))
{
arraycd($val);
}else{
$res_arr[]=$val;
}
}
}elseif(is_string($arr))
{
$res_arr[]=$arr;
}
return implode(",",$res_arr);
}
$fruits = array (
"fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"),
"numbers" => array(1, 2, 3, 4, 5, 6),
"holes" => array("first", 5 => "second", "third")
);
$strayy=arraycd($fruits);
var_dump($strayy);
相关阅读 更多 +