Created
July 23, 2012 15:50
-
-
Save joomlapro/3164342 to your computer and use it in GitHub Desktop.
Restyle value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Restyle value | |
* | |
* @param int $value The value to convert. | |
* | |
* @return string | |
* | |
* @since 2.5 | |
*/ | |
public static function restyleValue($value) | |
{ | |
$value = number_format($value); | |
$value_count = substr_count($value, ','); | |
if ($value_count != '0') | |
{ | |
if ($value_count == '1') | |
{ | |
return substr($value, 0, -4) . 'k'; | |
} | |
elseif ($value_count == '2') | |
{ | |
return substr($value, 0, -8) . 'mil'; | |
} | |
elseif ($value_count == '3') | |
{ | |
return substr($value, 0, -12) . 'bil'; | |
} | |
else | |
{ | |
return; | |
} | |
} | |
else | |
{ | |
return $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment