function cartesian($array,$arr = array()){
//去除第一个元素
$first = array_shift($array);
//判断是否是第一次进行拼接
if(count($arr) > 0) {
foreach ($arr as $k => $val) {
foreach ($first as $key => $value) {
$arr2[] = $val.','.$value;
}
}
}else{
foreach ($first as $key => $value) {
$arr2[] = $value;
}
}
//递归进行拼接
if(count($array) > 0){
$arr2 = $this->cartesian($array,$arr2);
}
//返回最终笛卡尔积
return $arr2;
}