RE: [PHP] RIGHT Function?
| From: | Jay Blanchard | Date: | Thu, 24 Sep 2009 19:15:13 +0000 |
| Subject: | RE: [PHP] RIGHT Function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298340@lists.php.net to get a copy of this message | ||
[snip]
I have a price field that sometimes contains entries like this:
250,(min)
5.32
How can I pull just the price ($5.32 in this example) from this
field
to display on a web page? Is there a RIGHT function in PHP? When I
search the PHP site, I'm being told there isn't one.
Here's the code I've been using:
[/snip]
substr will work from right to left.
If your data is in a variable do this;
echo substr($myData, -5);
Why -5? To account for 2 decimal places, the decimal and up to 99
dollars?
http://www.php.net/substr