<?php //string '2017-02-26 10:40:12' (length=19) $res= array( 'id' => '172', 'user_id' => '13', 'type' => '签到' , 'typename' => 'checkin' , 'id_status' => 'up', 'points' => '5', 'remark' => '奖励5积分', 'createtime' => '2017-02-27 13:40:42' ) $sign='['; foreach($res as $key=>$value){ $first=explode(' ', $value['createtime']); $second=explode('-', $first['0'])['2']; if($key==0){ $sign .= '{"signDay":"'.$second.'"}'; }else{ $sign .= ',{"signDay":"'.$second.'"}'; } } $sign .=']'; echo json_encode($sign); ?>