function slug($z){
$z = strtolower($z);
$z = preg_replace('/[^a-z0-9 -]+/', '', $z);
$z = str_replace(' ', '-', $z);
return trim($z, '-');
}
More Related Contents:
- Warning: preg_replace(): Unknown modifier
- Replace preg_replace() e modifier with preg_replace_callback
- Replace URLs in text with HTML links
- Remove all special characters from a string [duplicate]
- php regex to match outside of html tags
- Remove multiple whitespaces
- Convert plain text URLs into HTML hyperlinks in PHP
- PHP remove special character from string
- Replace multiple newlines, tabs, and spaces [duplicate]
- Extract URL from string
- What Delimiter to use for preg_replace in PHP (replace working outside of PHP but not inside)
- Regular expressions for a range of unicode points PHP
- How to remove diacritics from text?
- PHP using preg_replace : “Delimiter must not be alphanumeric or backslash” error
- Replace only first match using preg_replace [duplicate]
- Unknown modifier ‘/’ error in PHP [duplicate]
- Regex to strip comments and multi-line comments and empty lines
- Replace tabs and spaces with a single space as well as carriage returns and newlines with a single newline
- How to properly escape a backslash to match a literal backslash in single-quoted and double-quoted PHP regex patterns
- Remove all non-numeric characters from a string; [^0-9] doesn’t match as expected
- regular expression and forward slash
- Regex / DOMDocument – match and replace text not in a link
- PHP Preg-Replace more than one underscore
- Regex ignore URL already in HTML tags
- Replace all characters that aren’t letters and numbers with a hyphen [duplicate]
- Need a good regex to convert URLs to links but leave existing links alone
- PHP regular expression – filter number only
- ffmpeg Progress Bar – Encoding Percentage in PHP
- How to get all captures of subgroup matches with preg_match_all()? [duplicate]
- Validate date format in php