Created
June 24, 2019 13:34
-
-
Save aaronsummers/13c659b70623b5126bc5561fd0c39e4a to your computer and use it in GitHub Desktop.
Simple plural function php
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
<?php | |
function plural( $string ) { | |
$last_letter = substr($string, -1); // Get the last letter of the taxonomy name | |
if ( $last_letter != 's' ) : | |
// If it ends in a "Y" replace that with "IES" otherwise add an "S" | |
$string = ( $last_letter == 'y' ) ? substr($string, 0, -1) . 'ies' : $string . 's'; | |
endif; | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment