This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 剩余时间 | |
*/ | |
public static function remaintime($targettime) | |
{ | |
$nowtime = time(); | |
$re = array('day'=>0, 'hour'=>0, 'minute'=>0, 'second'=>0); | |
if ($targettime < $nowtime) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//判断一个对象是否是array类型 | |
var isArray : function(v){ | |
return toString.apply(v) === '[object Array]'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//生成随机字符串 | |
func RandStr(strlen int) string { | |
rand.Seed(time.Now().Unix()) | |
data := make([]byte, strlen) | |
var num int | |
for i := 0; i < strlen; i++ { | |
num = rand.Intn(57) + 65 | |
for { | |
if num>90 && num<97 { | |
num = rand.Intn(57) + 65 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 把ascii码转换成字符 | |
String.fromCharCode(65); | |
// 把字符转换成ascii码 | |
'Z'.charCodeAt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/md5" | |
"encoding/hex" | |
"fmt" | |
) | |
func main() { | |
h := md5.New() | |
h.Write([]byte("123456")) // 需要加密的字符串为 123456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//php 导出数据至excel | |
class ExportExcel | |
{ | |
/** | |
* 导出信息 | |
* | |
* @return null | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 转换时间戳为n天/小时/分/秒前 | |
* | |
* @param unknown $timestamp 时间戳 | |
* | |
* @return string | |
*/ | |
function convert2timeago($timestamp) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//判断是否手机号 | |
function isMobile(v) { | |
var reg = /^1[3|4|5|8][0-9]{9}$/; //手机号 | |
return reg.test(v); | |
} | |
//判断是否电话号码 | |
function isTel(v) { | |
var reg=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/; //电话号码 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JSON | |
{ | |
/** | |
* 使用特定function对数组中所有元素做处理 | |
* | |
* @param string &$array 要处理的字符串 | |
* @param string $function 要执行的函数 | |
* @param boolean $apply_to_keys_also 是否也应用到key上 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* post json数据 | |
* | |
* @param str $url posturl | |
* @param str $data_string json字符串 | |
* | |
* @return json_string | |
*/ | |
function postjson($url, $data_string) |
NewerOlder