Skip to content

Instantly share code, notes, and snippets.

View tekintian's full-sized avatar
🎯
Focusing

Tekin Tian tekintian

🎯
Focusing
View GitHub Profile
@tekintian
tekintian / xml_to_array.php
Created November 3, 2018 06:42
xml to array convert tool for php
<?php
function xml_to_array($xml)
{
preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $xml, $match);
$result = array();
foreach ($match[1] as $x => $y)
{
$result[$y] = $match[2][$x];
}
@tekintian
tekintian / cookie_get_set_del.js
Created May 2, 2018 03:33
js cookie获取删除设置函数js cookie delete get . and set
@tekintian
tekintian / date_diff.php
Created March 5, 2018 07:18
php 计算两个日期相隔时间:年、月、日、时、分、秒 总计天数
<?php
/**
* 计算两个日期相隔时间:年、月、日、时、分、秒 总计天数
* @author TekinTian <tekintian@gmail.com>
* @param string $start_time 开始时间 必须 [格式如:2011-11-5 10:01:01]
* @param string $end_time 结束时间 选填,不提供默认未当前时间 [格式如:2012-12-01 10:01:01]
* @return array Array ( [y] => 年 [m] => 月 [d] => 日 [h] => 时 [i] => 分 [s] => 秒 [a] => 合计天数 )
*/
function get_date_diff($start_time,$end_time=''){
@tekintian
tekintian / 防止刷新短信验证码获取, 无视刷新或者关闭浏览器!.html
Created February 12, 2018 11:28
防止刷新短信验证码获取, 无视刷新或者关闭浏览器! 采用jquery cookie
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Author" content="Tekin">
<meta name="Keywords" content="防止刷新短信验证码获取, 无视刷新或者关闭浏览器! jquery cookie">
<meta name="Description" content="防止刷新短信验证码获取, 无视刷新或者关闭浏览器! jquery cookie">
<title>防止刷新短信验证码获取, 无视刷新或者关闭浏览器! jquery cookie </title>
<script src="http://cdn.bootcss.com/jquery/3.1.0/jquery.js"></script>
<script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
@tekintian
tekintian / China Map Svg.html
Last active January 11, 2018 08:08
中国分省地图 SVG矢量地图文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>China Map Svg</title>
<link rel="stylesheet" href="">
</head>
@tekintian
tekintian / UrlQueryDemo.java
Created January 3, 2018 01:52
JAVA通过API方式请求远程API数据DEMO
package ws.yunnan;
import java.io.*;
import java.net.*;
public class QueryHelper {
public static String myip=null;
public static void main(String[] args) {
@tekintian
tekintian / javascript_ajax_function.js
Created January 3, 2018 01:49
原生javascript Ajax请求函数 示例
// 原生js Ajax请求函数
// javascript调用iP查询接口示例:
function ajax(params){
params = params||{};
if (!params.url) {
throw new Error('Necessary parameters are missing.'); //必要参数未填
}
var random = +new Date;
var hander = null;
var options = {
@tekintian
tekintian / replace_utf8_string.php
Created October 4, 2017 16:36
PHP仿淘宝隐藏用户名用星号代替
<?php
header('Content-type:text/html; charset=utf-8');
$str2 = $str = trim($_GET['str']);
//方法一:
echo mb_substr($str2, 0,1, 'UTF-8').'***'.mb_substr($str2, -1,1, 'UTF-8');
echo "<br/>";
//方法二:
$str = replace_utf8_string($str);
@tekintian
tekintian / gettime.php
Created September 17, 2017 03:30
转换剩余时间格式
<?php
//转换剩余时间格式
function gettime($time){
if ($time < 0) {
return '已结束';
} else {
if ($time < 60) {
return $time . '秒';
} else {
@tekintian
tekintian / collect_function_php_code.php
Created September 11, 2017 12:58
收集的一些常用的PHP函数
<?php
/**
* 数据XML编码
* @param mixed $data 数据
* @param string $item 数字索引时的节点名称
* @param string $id 数字索引key转换为的属性名
* @return string
*/
function data_to_xml($data, $item = 'item', $id = 'id') {