select('*')->from($tabName) ->where('ts')->ge($date . " 00:00:00") ->andWhere('ts')->le($date . " 23:59:59") ->count(); $array[] = intval($new); // 遍历 留存天数数组, 计算相应留存/率 array_map(function ($n)use($date, $tabName, $new, &$array, &$array2) { $iday = strtotime("$date +$n day"); $day = date("Y-m-d", $iday); $total = daoInst()->select('*')->from($tabName) ->where('ts')->ge($date . " 00:00:00") ->andWhere('ts')->le($date . " 23:59:59") ->andWhere('lastlogin')->ge($day . " 00:00:00") ->count(); $array[] = $total; # 输出 $array2[] = (int) ($total / $new * 100); # 输出 }, $numbers); // $result = new stdClass(); $result->data1 = $array; $result->data2 = $array2; echo json_encode($result);