normally php will output negative integer with this format -1234
, how to it show in parentheses format (1234)
example:
$foo = 10 - 20;
// output: $foo = -10
// expected output $foo = (10)
normally php will output negative integer with this format -1234
, how to it show in parentheses format (1234)
example:
$foo = 10 - 20;
// output: $foo = -10
// expected output $foo = (10)
I don't think there is a way to make PHP do this automatically.
echo ($foo < 0 ? "(".abs($foo).")" : $foo);
is the shortest solution that comes to mind.