Possible Duplicate:
How to prefix a positive number with plus sign in PHP
I have code similar to this
$points = -2;
$points = +2;
I want to display them as strings including the – or +. This works fine for the – but not for the +
I have tried this to try to get the positive sign
echo (string)$points;
Any ideas?
The positive sign is omitted because if a number isn’t negative, it’s positive.
You’ll have to use a function of sorts:
And you can use it like this:
Nope, I lied.
sprintf()seems like a better solution: