method changeCase documentation in bbn\Str

Converts the case of a string.

Example

$st = 'TEST CASE'; X::dump(\bbn\Str::changeCase($st, 'lower')); // (string) "test case" X::dump(\bbn\Str::changeCase('TEsT Case', 'upper')); // (string) "TEST CASE" X::dump(\bbn\Str::changeCase('test case')); // (string) "Test Case" function($st, $case = 'x') { $st = self::cast($st); $case = substr(strtolower((string)$case), 0, 1); switch ($case){ case "l": $case = MB_CASE_LOWER; break; case "u": $case = MB_CASE_UPPER; break; default: $case = MB_CASE_TITLE; } if (!empty($st)) { $st = mb_convert_case($st, $case); } return $st; }

Converts the case of a string. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.