Revision: 8956
Updated Code
at October 15, 2008 05:53 by DaveChild
Updated Code
function generate_url_from_text($strText) { $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText); $strText = preg_replace('/ +/', ' ', $strText); $strText = trim($strText); $strText = str_replace(' ', '-', $strText); $strText = preg_replace('/-+/', '-', $strText); $strText = strtolower($strText); return $strText; }
Revision: 8955
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 15, 2008 04:29 by DaveChild
Initial Code
function generate_url_from_text($strText) { $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText); $strText = preg_replace('/ +/', ' ', $strText); $strText = trim($strText); $strText = str_replace(' ', '-', $strText); $strText = strtolower($strText); return $strText; }
Initial URL
http://www.addedbytes.com
Initial Description
Function replaces all non-alpha-numeric chars and cleans up a text string. Should output a usable URL for almost all text.
Initial Title
PHP Generate URL From Text
Initial Tags
url, php
Initial Language
PHP