Remove Non English Characters PHP

后端 未结 4 1878
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 18:57

how can i parse a string to remove all non english characters in php

right now I want to remove things like

სოფო ნი�

Thanks :)

4条回答
  •  孤街浪徒
    2020-12-02 19:52

    By using preg_replace()

    $string = "some სოფო text"; 
    $string = preg_replace('/[^a-z0-9_ ]/i', '', $string); 
    
    echo $string;
    

    Granted, you will need to expand the preg_replace pattern, but that is one way to do it. There is probably a better way, I just do not know it.

提交回复
热议问题