Web Hosting Talk







View Full Version : Customized URLencode()


VolkNet
04-24-2005, 11:41 PM
I am trying to think of a way to rewrite a URL to work with how I want it.

For example I'm trying to have the spaces in the URL coded as - rather than +


<?php

function encode_url($url){

$newUrl = urlencode($url);
$urlnew = str_replace('+', '-', $newUrl);
return $urlnew;
}

print(encode_url("this is a test"));

?>

This works and prints out 'this-is-a-test'.

What I also would like to achieve using this is all the %20 and %21 etc codes to be removed. Can someone give me a list of all the common % codes? Thanks.

VolkNet
04-25-2005, 12:04 AM
http://www.w3schools.com/html/html_ref_urlencode.asp

opps sorry. I found what i was looking for :)

Well maybe someone can use the code above neways. ;)