Source for file modifier.ordinal_suffix.php
Documentation is available at modifier.ordinal_suffix.php
* -------------------------------------------------------------
* Purpose: show an integer in a human readable Byte size with optional resolution
* Example: {$someFile|filesize|display_bytes:2}
* -------------------------------------------------------------
// first convert to string if needed
// now we grab the last digit of the number
$last_digit = substr($ret, - 1, 1);
// if the string is more than 2 chars long, we get
// the second to last character to evaluate
$next_to_last = substr($ret, - 2, 1);
// now iterate through possibilities in a switch
// testing the second from last digit here
// testing the second from last digit here
// testing the second from last digit here
// for all the other numbers we use "th"
// finally, return our string with it's new suffix
return $pNum. tra( $suffix );
|