开发者

Extract commas from variable

Hey there, I have this variable:

<?php $blog_description = get_bloginfo('description'); ?>

$blog_description ='I am a text, I have commas, and periods. And I want the text without them';

How开发者_如何学Go can I extract the commas and periods from $blog_description? I want to use it as meta description in my website header.


$blog_description = str_replace(',', '', get_bloginfo('description'));

Or to remove commas and periods:

$blog_description = str_replace(array(',','.'), '', get_bloginfo('description'));

You can always use preg_replace too:

$blog_description = preg_replace('/[,\.]+/', '', get_bloginfo('description'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜