It is possible to run the urlencode function without converting # or % ?
+1
A:
There are a number of examples in the comments section on the PHP Docs of urlencode for alternative functions. You could simply take the most appropriate function for your needs and remove any replacements for # and %.
cballou
2009-11-04 20:00:57
+3
A:
Can you not just do:
$str = urlencode($str);
$str = str_replace("%23", "#", $str);
$str = str_replace("%25", "%", $str);
Dominic Rodger
2009-11-04 20:01:33
Mmmm less lines. +1
cballou
2009-11-04 20:02:10
nice solution!!!
Patrick
2009-11-04 20:07:50
+1
A:
I don't think so, but I guess you could replace the equivalent codes from the encoded string back with # and %.
luvieere
2009-11-04 20:01:43
A:
As far as I know, it's not possible with the urlencode function itself, but you could do a simple string replacement on the encoded results to achieve that:
function my_urlencode($input){
$input=urlencode($input);
return str_replace(array("%25","%23"),array("%","#"),$input);
}
pǝlɐɥʞ
2009-11-04 20:09:54