PHP Custom Urlencode,urldecode Function instance
This article mainly introduces the PHP custom Urlencode,urldecode function, the example analysis of PHP string transcoding skills, with a certain reference value, the need for friends can refer to the next
This example describes the PHP custom Urlencode,urldecode function. Share to everyone for your reference. Specific as follows:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13 |
With JavaScript's Ajaxobject function, the string is transcoded.
function Ajax_encode ($STR) {
$patern = Array ("/%/", "/=/", "/&/");
The% must be the first item, and the substitution is done in the order of the items.
$RP = Array ("%25", "%26", "%3d");
Return Preg_replace ($patern, $RP, $STR);
}
Inverse function
function Ajax_decode ($STR) {
$patern = Array ("/%25/", "/%26/", "/%3d/");
$RP = Array ("%", "=", "&");
Return Preg_replace ($patern, $RP, $STR);
}
|
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/973117.html www.bkjia.com true http://www.bkjia.com/PHPjc/973117.html techarticle PHP Custom Urlencode,urldecode Function Example This article mainly introduces the PHP custom Urlencode,urldecode function, the example analyzes the PHP string transcoding technique, has the reference price ...