Jump to content

String manipulation help needed


dwest

Recommended Posts

Hi,

I have a piece of data supplied as a dollar amount:

Example:

$1.95

 

However, if the dollar amount happens to end in zero, then is is supplied without the zero.

Example:

$1.9

 

So, I need to test for the second digit after the decimal and if it isn't there, add a zero.

 

How can I do that?

 

Maybe regexp is applicable here??

 

Any help would be greatly appreciated.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/97021-string-manipulation-help-needed/
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.