A better way to replace emoticons in PHP?

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

Right now I am using this function for emoticons:

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

        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 22:21

    Regular expressions are slow for this if the text is big, as much as i like them, you should only insert an icon if it's surrounded by spaces, that way your users won't riot when trying to write urls.

提交回复
热议问题