代码收藏

收集网站开发时常用到的代码(asp,php,js等)

« 货币数字转换为中文大写asp设置文件下载 »

自动检测内容是编码进行转换


$url = "http://www.163.com";
$data = file_get_contents($url);
$data = my_encoding($data,"utf-8");
echo "$data";

function my_encoding($data,$to)
{
$encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
$encoded = mb_detect_encoding($data, $encode_arr);
$data = mb_convert_encoding($data,$to,$encoded);
return $data;
}

?>
  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80605

Copyright 2008 ITlearner. Some Rights Reserved.