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'));
精彩评论