123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- use Illuminate\Support\Str;
- //判断等级
- function judge_level($level){
- switch ($level){
- case 2:
- $level='经销商';
- break;
- case 3:
- $level='批发商';
- break;
- }
- return $level;
- }
- function judge_level_name($level){
- switch ($level){
- case '经销商':
- $level=2;
- break;
- case '批发商':
- $level=3;
- break;
- }
- return $level;
- }
- function make_excerpt($value, $length = 200)
- {
- $excerpt = trim(preg_replace('/\r\n|\r|\n+/', ' ', strip_tags($value)));
- return str_limit($excerpt, $length);
- }
- function str_limit($value, $limit = 100, $end = '...')
- {
- return Str::limit($value, $limit, $end);
- }
- function code($phone){
- $data=md5(uniqid($phone));
- // return $data;
- $data=substr($data,1,6);
- return $data;
- }
- function str_random($length = 16)
- {
- return Str::random($length);
- }
- function hide_phone($phone){
- if (mb_strlen($phone)!=11){
- return '';
- }
- return mb_substr($phone,0,3).'****'.mb_substr($phone,7);
- }
- function auth_code($phone){
- $code_1=str_pad(random_int(1, 999), 3, 0, STR_PAD_LEFT);
- $code_2=mb_substr($phone,1,3);
- $code_3=str_pad(random_int(100, 99999), 6, 0, STR_PAD_LEFT);
- $code_4=mb_substr(time(),8,2);
- $code='DWBS00'.$code_1.date('ymd',time()).$code_2.$code_3.$code_4;
- return $code;
- }
- //function public_path($path = '')
- //{
- // return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
- //}
|