note 110302 deleted from function.urlencode by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Oct 2012 21:23:29 +0000 |
| Subject: | note 110302 deleted from function.urlencode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191388@lists.php.net to get a copy of this message | ||
Note Submitter: abhijeet9934 at gmail dot com
----
I have designed a new function to get the url encode it will be useful for the SEO url.
function customUrlEncode($string) {
$string = preg_replace('/\ /','-',$string);
$string = preg_replace('/\%/','-',$string);
$string = preg_replace('/\@/','-',$string);
$string = preg_replace('/\&/','-',$string);
$entities = array('%20','%21', '%2A', '%27',
'%28', '%29', '%3B', '%3A', '%40',
'%26', '%3D', '%2B', '%24', '%2C',
'%2F', '%3F', '%25', '%23', '%5B',
'%5D');
$replacements = array('-','-', '-', "-", "-",
"-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-",
"-", "-", "-");
return str_replace($entities, $replacements, urlencode($string));
}