• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
  • Класс: CIBlockCMLImport
  • Вызов: CIBlockCMLImport::safeTranslit
function safeTranslit($str)
{
	$params = array(
		"max_len" => 50,
		"change_case" => 'U', // 'L' - toLower, 'U' - toUpper, false - do not change
		"replace_space" => '_',
		"replace_other" => '_',
		"delete_repeat_replace" => true,
	);

	$result = CUtil::translit($str, LANGUAGE_ID, $params);
	$result = preg_replace("/[^a-zA-Z0-9_]/", $params["replace_other"], $result);
	if ($params["delete_repeat_replace"])
		$result = preg_replace("/".preg_quote($params["replace_other"], "/")."+/", $params["replace_other"], $result);

	return $result;
}