Automattic\WooCommerce\Blueprint
Util::camel_to_snake
Convert a string from camelCase to snake_case.
Метод класса: Util{}
Хуков нет.
Возвращает
Строку.
Использование
$result = Util::camel_to_snake( $input );
- $input(строка) (обязательный)
- The string to be converted.
Код Util::camel_to_snake() Util::camel to snake WC 11.0.1
public static function camel_to_snake( $input ) {
// Replace all uppercase letters with an underscore followed by the lowercase version of the letter.
$pattern = '/([a-z])([A-Z])/';
$replacement = '$1_$2';
$snake = preg_replace( $pattern, $replacement, $input );
// Replace spaces with underscores.
$snake = str_replace( ' ', '_', $snake );
// Convert the entire string to lowercase.
return strtolower( $snake );
}