Custom Meta Field – Remove comma from string with str_replace

I have a website that display car/vehicle listings. Each listing displays the PRICE. The price is set as a custom field on a custom post type, that is set to a string data type. The user typically types the price in as like 8,999. I need to echo/output/display the data with the comma removed, like this: 8999

Currently I display the data like this:

<?php echo get_post_meta($post->ID, “_price”, true); ?>

How can I use str_replace to output this data without the comma? Or is there a simpler, better way? Any suggestions would be appreciated.

Read more here:: Custom Meta Field – Remove comma from string with str_replace

Leave a Reply

Your email address will not be published. Required fields are marked *