首页 新闻 赞助 找找看

php语法改正

0
[已关闭问题] 关闭于 2017-03-07 15:24
<?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);
?>
php
飞离地平线的主页 飞离地平线 | 初学一级 | 园豆:16
提问于:2017-03-06 09:07
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册