Jump to content

[SOLVED] preg_replace?


tqla

Recommended Posts

Hello. My $beforediscountedPrice variable value is $75 and I need to use the value 75 without the dollar sign. How can I remove it?

 

I have tried:

$beforediscountedPrice = preg_replace('$','',$beforediscountedPrice);

 

But it does not work, How can I do this correctly?

 

Or, is there a way to convert monetary values that have a dollar sign to regular numbers?

Link to comment
https://forums.phpfreaks.com/topic/178645-solved-preg_replace/
Share on other sites

Although, if there is the possibility that it may not always be the first character that you need to get rid of, you can remove all characters that are not 0-9 or a decimal using the following:

$beforediscountedPrice = preg_replace('/[^\d.]/','',$beforediscountedPrice);

Link to comment
https://forums.phpfreaks.com/topic/178645-solved-preg_replace/#findComment-942321
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.