...

View Full Version : Change & to %26



NumBa1Stunna516
09-09-2005, 03:11 PM
Hey I was wondering if there was a php function that changes symbols to numbers such as the & sign to %26. Thanks.

e-Raser
09-09-2005, 04:07 PM
Yes str_replace()
For example,
$text = "The dog & I went home";
$text = str_replace("&","%26",$text);
// $text would now be The dog %26 I went home

http://www.php.net/str_replace

NumBa1Stunna516
09-09-2005, 04:27 PM
Sorry, I dont think I explained right. I want ALL symbols to be changed to that form. The thing is I dont know what its called, otherwise I could have looked it up. Here are some examples:

& = %26
@ = %40
# = %23

So basically what I want is if there is a symbol it should change to %something.

marek_mar
09-09-2005, 04:42 PM
urlencode() (http://www.php.net/urlencode) or rawurlencode() (http://www.php.net/rawurlencode) (preffered)

NumBa1Stunna516
09-09-2005, 04:54 PM
Thankyou marek_mar, thats exactly what I wanted.

marek_mar
09-09-2005, 05:11 PM
thats exactly what I wanted.
I know :cool: .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum