common.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @param string $address 地址
  4. * @return array
  5. */
  6. /**
  7. * 秒转换为天
  8. */
  9. function get_stay_time($remain_time, $is_hour = 1, $is_minutes = 1)
  10. {
  11. $day = floor($remain_time / (3600*24));
  12. $day = $day > 0 ? $day.'天' : '';
  13. $hour = floor(($remain_time % (3600*24)) / 3600);
  14. $hour = $hour > 0 ? $hour.'小时' : '';
  15. if($is_hour && $is_minutes) {
  16. $minutes = floor((($remain_time % (3600*24)) % 3600) / 60);
  17. $minutes = $minutes > 0 ? $minutes.'分钟' : '';
  18. return $day.$hour.$minutes;
  19. }
  20. if($hour) {
  21. return $day.$hour;
  22. }
  23. return $day;
  24. }
  25. //获取全图片地址 $image_data
  26. function image_path($image_data){
  27. if(empty($image_data)){
  28. return $image_data;
  29. }
  30. if (strpos($image_data,'|')!==false){
  31. $image_res = explode('|',$image_data);
  32. }elseif(strpos($image_data,',')!==false){
  33. $image_res = explode(',',$image_data);
  34. }else{
  35. $image_res = array($image_data);
  36. }
  37. return $image_res;
  38. }
  39. //通过user_id判断是用户还是媒体(返回1:用户 2:媒体)
  40. function user_type($user_id){
  41. $type = 1;
  42. if($user_id < 500){
  43. $type = 2;
  44. }
  45. return $type;
  46. }