在php页面中,$txt="时间"; 本echo $txt 时,是输出 时间二字的,
我想输出 shijian (就是把本应该输出的中文 换成 拼音输出)怎么弄呀,thanks

解决方案 »

  1.   

    不知道楼主是不是这个意思?
    [code=PHP]
    $txt="时间"; 
    if ($txt=="时间") $txt="shijian";
    echo $txt;
    [/code
      

  2.   

    1楼幽默啊,不错的办法~~http://www.xgdown.com/article/175/53672_1.htm
      

  3.   

    TO:3楼,有函数可以转换的,我在2楼留的地址:
    http://www.xgdown.com/article/175/53672_1.htm
    我没试过的啦,楼主可以试试
      

  4.   

    这个网络上有人做出来了。但是没什么实际意义。因为汉语拼音有太多音调,又分不同场地等原因调也不一样。
    当然如果只是单纯的把英文拼音转换出来的话还是有的。也是可以实现的。
    http://www.caisong.com/read.php/281.htm
      

  5.   

    <?php接二楼
     function g($num){
      global $d;
      if($num>0&&$num<160){
       return chr($num);
      }
      elseif($num<-20319||$num>-10247){
       return "";
      }else{
       for($i=count($d)-1;$i>=0;$i--){if($d[$i][1]<=$num)break;}
       return $d[$i][0];
      }
     } function c($str){
      $ret="";
      for($i=0;$i<strlen($str);$i++){
       $p=ord(substr($str,$i,1));
       if($p>160){
        $q=ord(substr($str,++$i,1));
        $p=$p*256+$q-65536;
       }
       $ret.=g($p);
      }
      return $ret;
     }
     
    // echo c("中国");?>
      

  6.   

    http://www.fyasp.com/Html/Article/asp/php/15925.html