我想以特定的方式在 php 中打印我的数组,我希望你能帮助我,非常感谢你。
public function getLineChartPromedio($format = 'Y-m-d'){
$startDate = $this->input->post('startDate');
$endDate = $this->input->post('endDate');
// Declare an empty array
$arraydias = array();
// Variable that store the date interval
// of period 1 day
$interval = new DateInterval('P1D');
$realEnd = new DateTime($endDate);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($startDate), $interval, $realEnd);
$count = 0;
// Use loop to store date into array
foreach($period as $date) {
$fecha = $date->format($format);
$arraydias [] = array ($fecha);
}
$string = "";
$week_array = "";
$size = 0;
foreach ($arraydias as $Array) {
$string .= implode("','", $Array);
$week_array = "'".$string."'";
}
echo json_encode($week_array);
}
该方法的结果为:“'2020-07-082020-07-092020-07-102020-07-112020-07-12'”
我想要实现的是:“'2020-07-08','2020-07-09','2020-07-10','2020-07-11','2020-07-12'”
我究竟做错了什么?我希望你可以帮助我
翻翻过去那场雪
holdtom
PIPIONE