Converting Microsoft Word special characters with PHP

前端 未结 4 558
忘了有多久
忘了有多久 2020-12-24 08:01

I am trying to convert Word text pasted by users that contain MS Word ellipsis and long dash before processing it further.

I found an old proposed solution here to t

4条回答
  •  轮回少年
    2020-12-24 08:31

    it works for me:

    $str=file_get_contents($file); 
    
    $array=array("‘"=>"'","’"=>"'","”"=>'"',"“"=>'"',"–"=>"-","—"=>"-","–"=>"-","…"=>"...");
    
    $str = strtr( $str,$array);
    
    file_put_contents($file,$str);  
    

提交回复
热议问题