Click to See Complete Forum and Search --> : Post title > Page title


Tabo
07-27-2008, 09:40 AM
Lets say someone posts a page with the title:

Hello!!! What is 1 + 1 (^5) ??

Basically with special chars.

I want to change my site so that urls are like:

mysite.com/hello_what_is_1_1_5

or something which contains acceptable chars and no escaped chars,
can you point me to a php script or provide me one which does this?

erwanpia
07-27-2008, 09:55 AM
What you need is to remove characters that are not in a specific range .Try this
regular expression
$pattern = "([^[[:alnum:]|[:space:]|[:blank:]])+";

like_php
07-27-2008, 10:27 AM
look at this link

http://php.net/htmlspecialchars

hope it help

malarz
07-27-2008, 10:48 AM
You can do it like this:

$string=str_replace(' ', '_', $string); // all spaces to '_'
$string=preg_replace('/[^a-zA-Z0-9_]/', '', $string); // remove all bad characters