Replace diacritic characters with “equivalent” ASCII in PHP?

前端 未结 4 1046
情深已故
情深已故 2021-01-31 20:42

Related questions:

  1. How to replace characters in a java String?
  2. How to replace special characters with their equivalent (such as " á " for &
4条回答
  •  余生分开走
    2021-01-31 21:13

    My solution is to create two strings - first with not wanted letters and second with letters that will replace firsts.

    $from = 'čšć';
    $to   = 'csc';
    $text = 'Gračišće';
    
    $result = str_replace(str_split($from), str_split($to), $text);
    

提交回复
热议问题