1 handlers.inc | views_handler::case_transform($string, $option) |
Transform a string by a certain method.
Parameters
$string: The input you want to transform.
$option: How do you want to transform it, possible values:
- upper: Uppercase the string.
- lower: lowercase the string.
- ucfirst: Make the first char uppercase.
- ucwords: Make each word in the string uppercase.
Return value
string: The transformed string.
File
- core/
modules/ views/ includes/ handlers.inc, line 244 - Defines the various handler objects to help build and display views.
Class
- views_handler
- Base handler, from which all the other handlers are derived. It creates a common interface to create consistency amongst handlers and data.
Code
function case_transform($string, $option) {
global $multibyte;
switch ($option) {
default:
return $string;
case 'upper':
return backdrop_strtoupper($string);
case 'lower':
return backdrop_strtolower($string);
case 'ucfirst':
return backdrop_strtoupper(backdrop_substr($string, 0, 1)) . backdrop_substr($string, 1);
case 'ucwords':
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_convert_case($string, MB_CASE_TITLE);
}
else {
return ucwords($string);
}
}
}