Need weird PHP help (2.1.5)
Zhaan
✭✭
So.. I'm currently styling the "comment count" and "view count" for my new theme, but I need to make it display two zeros before each singular number. Like this:
Discussion (001 comments)
instead of
Discusion (1 comments)
..however, I do not want discussions with 3 or more digits to be affected.
I know it might sound silly, but this would help me achieve the weirdo style I'm going for. 
Looking into the code.. I found this in views>discussions>helper_functions, and thought maybe it could be edited:
<?php
printf(PluralTranslate($Discussion->CountComments,
'%s html', '%s html', '%s ', '%s '),
BigPlural($Discussion->CountComments, '%s '));
?>
What do you think? I'd appreacite any help here. 
0
Best Answer
-
hgtonight
MVP
You are looking to pad the number to a specific number of digits. Knowing this, it is much easier to google for:
http://php.net/manual/en/function.str-pad.php
Example:
echo str_pad($Discussion->CountComments, 3, '0', STR_PAD_LEFT);
7
Answers
You are looking to pad the number to a specific number of digits. Knowing this, it is much easier to google for:
http://php.net/manual/en/function.str-pad.php
Example:
Thanks!