12 lines
376 B
PHP
12 lines
376 B
PHP
function strToElementCode($str, $maxLength = 100) {
|
|
if ($maxLength < 1) {
|
|
throw new InvalidArgumentException('maxLength must be positive');
|
|
}
|
|
return CUtil::translit($str, 'ru', [
|
|
'max_len' => $maxLength,
|
|
'change_case' => 'L',
|
|
'replace_space' => '_',
|
|
'replace_other' => '_',
|
|
'delete_repeat_replace' => true,
|
|
]);
|
|
} |