如何從文本中替換或過濾不良詞語,如str_ireplace? 我需要從數組中替換單詞中的值,但不使用foreach和爆炸。PHP將單詞從鍵值替換爲數組中的值
例陣列
$_filter = [
'badwords' => [
'one' => 'time',
'bad' => 'good',
'ugly' => 'beauty'
]
];
實施例替換
$before = 'anyone help me please';
$after = 'anytime help me please';
$before = 'I need BaD function';
$after = 'I need good function';
$before = 'I am so (ugly)';
$after = 'I am so (beauty)';
試圖these但不工作。 任何人都可以幫助我。謝謝
謝謝你,array_keys是我的問題,完善功能 – Baron