Skip to content

Instantly share code, notes, and snippets.

@joomlapro
Created July 23, 2012 15:50
Show Gist options
  • Save joomlapro/3164342 to your computer and use it in GitHub Desktop.
Save joomlapro/3164342 to your computer and use it in GitHub Desktop.
Restyle value
/**
* 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