php中将ascii转字符串的办法:默许以后的php文件环境是【UTF-8】,假如是GBK的话将【mb_convert_encoding】省略便可,代码为【function asciitostr($sacii)】。
php中将ascii转字符串的办法:
将字符串(支持中文)转为ascii
留意:默许以后的php文件环境是UTF-8,假如是GBK的话mb_convert_encoding
可省略。
function strtoascii($str){ $str=mb_convert_encoding($str,'GB2312'); $change_after=''; for($i=0;$i<strlen($str);$i++){ $temp_str=dechex(ord($str[$i])); $change_after.=$temp_str[1].$temp_str[0]; } return strtoupper($change_after); }//strtoascii function asciitostr($sacii){ $asc_arr= str_split(strtolower($sacii),2); $str=''; for($i=0;$i<count($asc_arr);$i++){ $str.=chr(hexdec($asc_arr[$i][1].$asc_arr[$i][0])); } return mb_convert_encoding($str,'UTF-8','GB2312'); }
相干学习保举:PHP编程从入门到通晓
以上就是php中若何将ascii转字符串?的具体内容,更多请存眷资源魔其它相干文章!
标签: php php教程 字符串 php故障解决 php使用问题 ascii
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!