View Full Version : Change & to %26

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

09-09-2005, 03: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


09-09-2005, 03: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.

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

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

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum