use yii\helpers\Inflector; $input = "Hello, world! How are you?"; $variableName = Inflector::variablize($input); // "helloWorldHowAreYou"This helper function is part of the Inflector package library, which provides various string manipulation functions.