/    Sign up×
Community /Pin to ProfileBookmark

Post title > Page title

Lets say someone posts a page with the title:

[COLOR=”RoyalBlue”]Hello!!! What is 1 + 1 (^5) ??[/COLOR]

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?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@erwanpiaJul 27.2008 — What you need is to remove characters that are not in a specific range .Try this

regular expression

$pattern = "([^[[:alnum:]|[:space:]|[:blank:]])+";
Copy linkTweet thisAlerts:
@like_phpJul 27.2008 — look at this link

http://php.net/htmlspecialchars

hope it help
Copy linkTweet thisAlerts:
@malarzJul 27.2008 — You can do it like this:
<i>
</i>$string=str_replace(' ', '_', $string); // all spaces to '_'
$string=preg_replace('/[^a-zA-Z0-9_]/', '', $string); // remove all bad characters
×

Success!

Help @Tabo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...