Location: PHPKode > projects > Anchor CMS > anchorcms-anchor-cms-b327dd9/system/library/str.php
<?php defined('IN_CMS') or die('No direct access allowed.');

class Str {

	public static function random($length) {
		$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
	}

	public static function ascii($value) {
		$foreign = Config::get('foreign_characters');

		$value = preg_replace(array_keys($foreign), array_values($foreign), $value);

		return preg_replace('/[^\x09\x0A\x0D\x20-\x7E]/', '', $value);
	}

	public static function slug($title) {
		$title = static::ascii($title);
		$separator = '-';

		// Remove all characters that are not the separator, letters, numbers, or whitespace.
		$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', static::lower($title));

		// Replace all separator characters and whitespace by a single separator
		$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);

		return trim($title, $separator);
	}

	public static function lower($value) {
		return function_exists('mb_strtolower') ? mb_strtolower($value, 'UTF-8') : strtolower($value);
	}

}
Return current item: Anchor CMS