You are here

public static function SampleDataLoader::slugify in YAML Content 8.2

Helper function to convert non-alphanumeric characters into dash.

Parameters

string $str: The string to convert.

string $replace: The string to replace non-alphanumeric characters.

Return value

string The converted string.

File

modules/sample_data/src/SampleDataLoader.php, line 255

Class

SampleDataLoader
Provides methods for retrieving sample data to be used in demo content.

Namespace

Drupal\sample_data

Code

public static function slugify($str, $replace = '-') {
  return preg_replace("/[^a-z0-9]/", $replace, strtolower($str));
}