How to convert UTF8 characters to numeric character entities in PHP

前端 未结 1 795
时光说笑
时光说笑 2021-02-04 09:24

Is a translation of the below code at all possible using PHP?

The code below is written in JavaScript. It returns html with numeric character references where needed. Ex

1条回答
  •  醉梦人生
    2021-02-04 09:59

    Use mb_encode_numericentity:

    $convmap = array(0x80, 0xffff, 0, 0xffff);
    echo mb_encode_numericentity($utf8Str, $convmap, 'UTF-8');
    

    0 讨论(0)
提交回复
热议问题