A better way to replace emoticons in PHP?

后端 未结 5 1539
忘掉有多难
忘掉有多难 2020-12-05 21:40

Right now I am using this function for emoticons:

function emoticons($text) {
        $icons = array(
                \':)\'    =>  \'

        
5条回答
  •  臣服心动
    2020-12-05 22:17

    I think using regular expressions instead of just defining your emoticons. This could look like

    // replaces a :) when it is surrounded by whitespaces
    return preg_replace('/\s:)\s/', '', $text);
    

提交回复
热议问题