手机号编码解码
2016-07-02 00:59
190 查看
//推荐人号码 $link['referrer_mobile'] = self::_decode($_POST['referrer_mobile']);
/** * 编码 PS:传入 手机号 返回 字符串 * @param unknown $s * @return string */ private static function _encode($s) { $len = strlen($s); $newstr=''; for ($i=0; $i<$len; $i++) { $newstr .= str_pad(dechex(ord($s[$i])), 2, '0', STR_PAD_LEFT); } return $newstr; } /** * 解码 PS:传入 字符串 返回 手机号 * @param unknown $s * @return string */ private static function _decode($s) { $strArr = str_split($s, 2); $newstr = ''; foreach ( $strArr as $hexStr ) { $newstr .= chr(hexdec($hexStr)); } return $newstr; }
相关文章推荐
- poj1837 Balance (二维费用背包&&分组背包)
- ElasticSearch源码解析(一):转一篇介绍中文分词的文章
- python str的一些方法
- 安卓学习之—自定义ProgressBar的样式
- 进程通信--无名管道
- nginx负载均衡详细配置
- Java NIO原理及实例
- new与delete创建对象
- uva 455 Periodic Strings(暴力 判断周期串)
- Python中的join()函数的用法
- Lync(Skype)接口开发实录
- 利用信鸽推送提示评论通知
- 通用后台管理系统(ExtJS 4.2 + Spring MVC 3.2 + Hibernate)
- oracle间断性走错执行计划
- Intent 用法总结
- Compiling Qt 5.5.1 (With Qtwebkit) With Visual Studio 2015
- Spring Boot / Spring MVC 入门实践 (一) :环境搭建与第一个项目
- CTC学习笔记(三) 解码
- 菜鸟一枚,记录成长(2)
- Ubuntu系统安装、网络配置、lamp环境搭建