Last active
August 29, 2015 14:07
-
-
Save ScreamingDev/acca1a6eaaca0cda0d75 to your computer and use it in GitHub Desktop.
ngettext for and encounting
This file contains hidden or 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
<?php | |
$enum = array(); | |
// fetch last or a message for none | |
($last = array_pop($enum)) || ($last = __('none')); | |
// make a message depending on the number of elements | |
$message = vsprintf( | |
ngettext( | |
'There is %s', | |
'There is %s and %s', | |
count($enum)+1 | |
), | |
array_merge($enum, (array) $last) // combine to one | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment