Skip to content

Instantly share code, notes, and snippets.

@isecret
Last active December 14, 2018 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isecret/50d56a343e1d78b10e266359051ea1ba to your computer and use it in GitHub Desktop.
Save isecret/50d56a343e1d78b10e266359051ea1ba to your computer and use it in GitHub Desktop.
WordPress conversion expression for Laravel
.
.
.
public function handle()
{
$em = [
"/weixiao",
"/nanguo",
"/qiudale",
"/penxue",
"/piezui",
"/aoman",
"/baiyan",
"/bishi",
"/bizui",
"/cahan",
"/ciya",
"/dabing",
"/daku",
"/deyi",
"/doge",
"/fadai",
"/fanu",
"/fendou",
"/ganga",
"/guzhang",
"/haixiu",
"/hanxiao",
"/haqian",
"/huaixiao",
"/jie",
"/jingkong",
"/jingxi",
"/jingya",
"/keai",
"/kelian",
"/koubi",
"/ku",
"/kuaikule",
"/kulou",
"/kun",
"/leiben",
"/lenghan",
"/liuhan",
"/liulei",
"/qiaoda",
"/qinqin",
"/saorao",
"/se",
"/shuai",
"/shui",
"/tiaopi",
"/touxiao",
"/tu",
"/tuosai",
"/weiqu",
"/wozuimei",
"/wunai",
"/xia",
"/xiaojiujie",
"/xiaoku",
"/xieyanxiao",
"/xu",
"/yinxian",
"/yiwen",
"/zuohengheng",
"/youhengheng",
"/yun",
"/zaijian",
"/zhayanjian",
"/zhemo",
"/zhouma",
"/zhuakuang",
"/aini",
"/baoquan",
"/gouyin",
"/qiang",
"OK",
"/woshou",
"/quantou",
"/shengli",
"/aixin",
"/bangbangtang",
"/baojin",
"/caidao",
"/lanqiu",
"/chi",
"/dan",
"/haobang",
"/hecai",
"/hexie",
"/juhua",
"/pijiu",
"/shouqiang",
"/xiaoyanger",
"/xigua",
"/yangtuo",
"/youling",
'/色',
'/难过',
'/闭嘴',
'/吐舌头',
'/微笑',
'/可爱',
'/kiss',
'/惊讶',
'/饥饿',
'/晕',
'/酷',
'/坏笑',
'/发怒',
'/憨笑',
'/萌萌哒',
'/吃东西',
'/色咪咪',
'/囧',
'/害羞',
'/流泪',
'/流汗',
'/你懂的'
];
usort($em, function ($a,$b) {
return strlen($b)-strlen($a);
});
$comments = Comment::all();
foreach ($comments as $comment) {
foreach ($em as $e) {
if (str_contains($comment->comment_content, $e)) {
$comment->comment_content = str_replace($e, '['.trim($e, '/').']', $comment->comment_content);
$comment->save();
}
}
}
}
.
.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment