普通网友 2015-03-19 22:25
浏览 27
已采纳

PHP显示奇怪的汉字?

I am having a few problems with this code, one is that the proxies are not being displayed on a new line for each one.

Two is that instead of the "
" being displayed these weird chinese characters are being displayed 䈼㹒

<?php

$data = file_get_contents("http://proxylists.connectionincognito.com/proxies_657.txt");

  //var_dump($data);
$lines = explode("/n", $data);

  foreach($lines as $line)
{

  echo $line;
  echo "<BR>";

}


?>
  • 写回答

1条回答 默认 最新

  • duanjing9339 2015-03-19 22:27
    关注

    Try to explode by " " instead of "/n".

    The Chinese charakters are there because the file is encoded in UTF-16, so you need to do this:

    $data = mb_convert_encoding($data,'UTF-8','UTF-16');
    

    before you start to work with the data. I made a working example here:

    http://www.servisio.com/test.html

    It contains these four lines:

    $data  = file_get_contents("http://proxylists.connectionincognito.com/proxies_657.txt");
    $data  = mb_convert_encoding($data,'UTF-8','UTF-16');
    $lines = explode("
    ", $data);
    foreach($lines as $line) echo $line.'<br>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++识别堆叠物体异常
  • ¥15 音量自动减小啦!日历自动翻页
  • ¥15 微软硬件驱动认证账号申请
  • ¥15 有人知道怎么在R语言里下载Git上的miceco这个包吗
  • ¥15 GPT写作提示指令词
  • ¥20 如何在cst中建立这种螺旋扇叶结构
  • ¥20 根据动态演化博弈支付矩阵完成复制动态方程求解和演化相图分析等
  • ¥20 关于DAC输出1.000V对分辨率和精度的要求
  • ¥15 华为超融合部署环境下RedHat虚拟机分区扩容问题
  • ¥15 哪位能做百度地图导航触点播报?