如何删除括号并从数组中插入逗号(,)?
我的代码输出:($ var_array)
Array ( [06] => Body Weight Squat [04] => Body Weight Squat )
期望:($ var_new_array)
array(
06 => 'Body Weight Squat',
04 => 'Body Weight Squat'
)
代码:
$data['year'] = $year;
$data['month'] = $month;
$query = $this->daysmodel->fetch_exercises_byForDate($year.'-'.$month.'-');
$data['query']=$query;
$array[] = [];
foreach ($query as $row) {
$date=$row->for_date;
$array[date('d', strtotime($date))] = $row->menu_name ;
}
$newArray= $this->array_flatten($array);
print_r( $newArray);// Array ( [06] => Body Weight Squat [04] => Body Weight Squat )
$this->load->view('calender/myCalender', $data);
答案 0 :(得分:0)
只需删除
$array[] = [];
并直接使用$array[]
。
它肯定会有用。