小编Zor*_*ric的帖子

用星号替换单词(确切长度)

我试图替换字符串中的单词但是我想在函数中找到单词并将其替换为带有确切长度的星号的单词?

这是可能的还是我需要以其他方式做到这一点?

$text = "Hello world, its 2018";
$words = ['world', 'its'];


echo str_replace($words, str_repeat("*", count(FOUND) ), $text);
Run Code Online (Sandbox Code Playgroud)

php replace str-replace

0
推荐指数
1
解决办法
466
查看次数

标签 统计

php ×1

replace ×1

str-replace ×1