Function : toSingular

This function converts a string to singular by removing the last "s" or "S" character. The argument can also take a list of array strings.

Syntax
  toSingular($value)
  
  $value: string or array of strings
   
                  
Sample 1
  echo( toSingular('boys') ); //boy
                  
The last "s" character of the text above was removed
Sample 2
  echo( toSingular('BOYS') ); //BOY
                  
The last "S" character of the text above was removed
Sample 3
  echo( toSingular('glass') ); //glas
                  
The function does not use a dictionary to determine the type of word supplied. Hence, the last "s" character in the word above was removed.
Sample 4
  echo( toSingular('boy') ); //boy
                  
The text above remains the same because there is no lasting "S" or "s" character that was found to be stripped off.
Sample 5
  var_dump( toSingular(['boys', 'books']) ); //['boy', 'book']