Variable Visions

Articles PHP PHP-preg-replace-for-adding-hyphens-to-URL-field


tutorials - PHP and Web-Development.

PHP preg_replace for adding hyphens to URL field

Published Thu. Aug. 02, 2012


Set this variable eqaul to your POST value for URL title and it will automatically add hyphens where spaces are found.

$urltitle = preg_replace('/[^A-Za-z0-9-]+/', '-', $urltitle);


Tag(s): PHP, preg_replace, query string urls