function to_last_month($num){ $today = date("Y-m-d"); $arr = array(); $m = '-'.$num.' month'; $old_time = strtotime($m,strtotime($today)); for($i = 0;$i <= $num-1; ++$i){ $t = strtotime("+$i month",$old_time); $arr[] = date('y年m月',$t); } //return $str = "'".str_replace( ",","','", implode(',',$arr))."'"; return json_encode($arr); }