Skip to content

Instantly share code, notes, and snippets.

@MartinTale
Created December 17, 2019 15:46
Show Gist options
  • Save MartinTale/3696e4a2aa9374f7b569ecbedaad4446 to your computer and use it in GitHub Desktop.
Save MartinTale/3696e4a2aa9374f7b569ecbedaad4446 to your computer and use it in GitHub Desktop.
PHP function that converts number to a number with sign in front of it..
<?php
if (! function_exists('numberWithSign'))
{
function numberWithSign($number)
{
if ($number < 0) {
return round($number, 2);
} else {
return '+' . round($number, 2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment