Jam*_*don 43 php string str-replace
我希望能够替换空格,-但也想删除逗号和问号.我怎么能在一个函数中做到这一点?
到目前为止,我有它替换空格:
str_replace(" ","-",$title)
Run Code Online (Sandbox Code Playgroud)
Nap*_*lux 184
您可以将数组作为参数传递给str_replace().检查手册.
// Provides: You should eat pizza, beer, and ice cream every day
$phrase = "You should eat fruits, vegetables, and fiber every day.";
$healthy = ["fruits", "vegetables", "fiber"];
$yummy = ["pizza", "beer", "ice cream"];
$newPhrase = str_replace($healthy, $yummy, $phrase);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
74246 次 |
| 最近记录: |