开发者

Extract commas from variable

开发者 https://www.devze.com 2023-03-04 13:36 出处:网络
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\';

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

精彩评论

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