use yii\helpers\Inflector; $string = "Hello, World!"; $slug = Inflector::slug($string); echo $slug; // Output: hello-world
use yii\helpers\Inflector; $string = "Yii is a PHP framework."; $slug = Inflector::slug($string, '-', true); echo $slug; // Output: yii-is-a-php-frameworkIn this example, we pass an additional parameter to the slug() method to specify a custom delimiter. We also set a boolean value to true to make the slug lowercase. The Inflector class is part of the Yii2 framework's Helpers package library. This library provides useful functions and utilities to streamline your web application development process.