How To Remove Special Characters From Urls HTML PHP Link Linking Removing



How To Remove Special Characters From Urls HTML PHP Link Linking Removing
 (328) Domains for just $1.99 1751586
How To Remove Special Characters From Urls HTML PHP Link Linking Removing
Post Description:
Post Tags: how, to, remove, special, characters, from, urls, html, php, link, linking, removing
This Post Has Been Viewed 3470 Times Since Sun Apr 08, 2007 4:05 pm Posted By hostman with 4 replies
How To Remove Special Characters From Urls HTML PHP Link Linking Removing
today i came across someting which i use frequently for all of my mod_rewrite urls. I had this web site that wanted the title on their url but i noticed that some titles had weird special characters you find on your keyboard for example some of them are these

! @ # $ % ^ & * ( ) _ + { } | : " < > ? [ ] \ ; ' , . / / * - + ~ ` - = space


so lets say for example i have a page title called:
I am this @ thisdomain.com! [contact] & phone # (213) 555-1212

as you can see from my example title, i would have to make the url look like this:
I am this @ thisdomain.com! [contact] & phone # (213) 555-1212.html

That just wouldn't work, how about if i could make it look like this:
i-am-this-thisdomain-com-contact-phone-213-555-1212.html

So how can you do this. Well, if you have PHP you can very easy. So I created a function to make this possible and this is the script code:

     Code:
<?php
# This function makes any text into a url frienly
# This script is created by wallpaperama.com
function clean_url($text)
{
$text=strtolower($text);
$code_entities_match = array(' ','--','&quot;','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
$code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
$text = str_replace($code_entities_match, $code_entities_replace, $text);
return $text;
}
?>


This function will make your url look shorter and it will be search engine friendly. it will remove all those unwantd spcial characters you find on your keyboard above the number 1234567890 and some others, this way you links witll look better and liking to them will be easier by removing all the unwanted special strings with a simple php function snippet wiget in your html web pages.

NOTE: this will only work if you have php, if you don't you can visit our friends at www.webune.com and sign up with on of their PHP web hosting plans.

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Remove Special Characters From Urls HTML PHP Link Linking Removing




:: 1 :: #28994 - Reply By AbhinavZone On Fri Nov 23, 2007 10:42 pm
hey thanx buddy!!! gr8 post
:: 2 :: #30752 - Reply By Prashant On Thu Dec 06, 2007 3:20 am
excellent. very good example.

thanks
:: 3 :: #35573 - Reply By KCJ-pop On Wed Jan 09, 2008 9:02 am
thank you so much for this useful function. i googled it for a while and i found here. thank again. keep up your good job!
:: 4 :: #58124 - Reply By sezer On Tue Jun 17, 2008 9:17 am
html special characters --
html-lesson.blogspot /2008/06/special-characters.html