removing strange characters from php string

前端 未结 14 957
忘了有多久
忘了有多久 2021-01-31 17:45

this is what i have right now

Drawing an RSS feed into the php, the raw xml from the rss feed reads:

Paul’s Confidence

The ph

14条回答
  •  时光取名叫无心
    2021-01-31 18:21

    Please Try this. 
    
    
    $find[] = '/“/' //'“'; // left side double smart quote
    $find[] = '/”/' //'â€'; // right side double smart quote
    $find[] = '/‘/' //'‘'; // left side single smart quote
    $find[] = '/’/' //'’'; // right side single smart quote
    $find[] = '/ /'  //'…'; // elipsis
    $find[] = '/‖/' //'—'; // em dash
    $find[] = '/–/' //'–'; // en dash
    
    $replace[] = '“' // '"';
    $replace[] = '”' // '"';
    $replace[] = '‘' // "'";
    $replace[] = '’' // "'";
    $replace[] = '⋯' // "...";
    $replace[] = '—' // "-";
    $replace[] = '–' // "-";
    
    $text = str_replace($find, $replace, $text);
    

提交回复
热议问题