複製程式碼程式碼如下:
/*
* ————————————————— —-
* @file : 5.php
* @function : arr2str
* @copyright : 2002-2009 Xingmo Inc
* @author : 含> * @date : 2010-06-25
* @update :
* —————————————————-
*/
$fruits = array (
"fruits" => array("a" => "柳橙", "b" => "香蕉", "c" => "蘋果" ),
"數字" => 陣列(1, 2, 3, 4, 5, 6),
"洞" => 陣列("第一個", 5 => "第二個", "第三")
);
$arr1 = array(1, 2, 3, 4, 5, 6=>'fanglor');
函數arr2str ($arr)
{
靜態$res_arr = array ();
if (is_array ($arr))
{
foreach ($arr as $key => $val )
{
if (is_array($val))
{
arr2str ($val);
}
其他
{
$res_arr[] = $val;
}
}
}
elseifif (is_string ($arr))
{
$res_arr[] = $arr;
}
回傳內爆(',',$res_arr);
}
$str = arr2str ($arr1);
print_r ($str);
? >