当前位置:Gxlcms > PHP教程 > php连续留存与留存人数计算

php连续留存与留存人数计算

时间:2021-07-01 10:21:17 帮助过:22人阅读

  1. for($i = 0;$i <= $interval;$i++) {
  2. $res = $model->turnround($today,$tomorrow,$flag);
  3. $temp = array();
  4. foreach($res as $value){
  5. $inmatch = isset($value['inmatch']) ? json_decode($value['inmatch']) : array();
  6. foreach($inmatch as $val) {
  7. if(!in_array($val, $temp)) {
  8. array_unshift($temp,$val);
  9. }
  10. }
  11. }
  12. $i==0 ? $total = count($temp) : "";
  13. $temp = array_fill_keys($temp, $i);
  14. foreach($temp as $k=>$v) {
  15. if(array_key_exists($k,$stats)) {
  16. $stats[$k] = $stats[$k].",".$v;
  17. } else {
  18. $stats[$k] = $v;
  19. }
  20. }
  21. $today = $today + 86400;
  22. $tomorrow = $tomorrow + 86400;
  23. }
  24. $strlen = ($interval+1)*2-1;
  25. foreach($stats as $v) {
  26. if(isset($v)) {
  27. strlen(trim($v)) == $strlen ? $num++ : $num;
  28. }
  29. }
  30. $ret['turnround']['all'] = $stats;
  31. $ret['turnround']['total'] = $total;
  32. $ret['turnround']['stats'] = count($stats);
  33. $ret['turnround']['num'] = $num;
  34. */
  35. $res = $model->turnround($today,$tomorrow,$flag);
  36. $todayPeople = array();
  37. foreach($res as $value){
  38. $inmatch = isset($value['inmatch']) ? json_decode($value['inmatch']) : array();
  39. foreach($inmatch as $val) {
  40. if(!in_array($val, $todayPeople)) {
  41. array_unshift($todayPeople,$val);
  42. }
  43. }
  44. }
  45. $todayNum = count($todayPeople);
  46. $atToday = $today + $interval*86400;
  47. $atTomorrow = $tomorrow + $interval*86400;
  48. $atRes = $model->turnround($atToday,$atTomorrow,$flag);
  49. $atPeople = array();
  50. foreach($atRes as $v){
  51. $atInmatch = isset($v['inmatch']) ? json_decode($v['inmatch']) : array();
  52. foreach($atInmatch as $val) {
  53. if(!in_array($val, $atPeople)) {
  54. array_unshift($atPeople,$val);
  55. }
  56. }
  57. }
  58. $same = array_intersect($todayPeople,$atPeople);
  59. $atNum= count($same);
  60. $ret['turnround']['all'] = $todayPeople;
  61. $ret['turnround']['total'] = $todayNum;
  62. $ret['turnround']['stats'] = "";
  63. $ret['turnround']['num'] = $atNum;

以上就介绍了php 连续留存与留存人数计算,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行