PHP string echoing with " around strings
I have the php function I am trying use,
echo get_products_display_price($_GET['products_id']);
my out put is "$199.99" with the quotes, is there a way to get it to output with out the " around the string without having to mess much wit开发者_StackOverflow中文版h the function itself something like substr
?
You can use trim
:
echo trim(get_products_display_price($_GET['products_id']), "'\" ");
It will remove all "
, '
and white spaces at the beginning and end of the string.
But I am wondering why the quotes are displayed. If you are echoing strings, normally the quotes are not printed as long as they are not part of the strings itself. You should check your get_products_display_price
function and fix the error there.
echo str_replace('"','',get_products_display_price($_GET['products_id']));
or
ereg_replace('"', '', get_products_display_price($_GET['products_id']));
精彩评论