This article mainly introduces php user-defined urlencode and urldecode functions. The example analyzes php string transcoding techniques and has some reference value, you can refer to the following example to describe the php user-defined urlencode and urldecode functions. Share it with you for your reference. The details are as follows:
// Use the JavaScript ajaxObject function to transcode the string. function ajax_encode ($ str) {$ patern = array ("/%/", "/=/", "/&/"); // % must be the first item, replacement is performed in the order of items. $ rp = array ("% 25", "% 26", "% 3D"); return preg_replace ($ patern, $ rp, $ str );} // inverse function ajax_decode ($ str) {$ patern = array ("/% 25/", "/% 26/", "/% 3D /"); $ rp = array ("%", "=", "&"); return preg_replace ($ patern, $ rp, $ str );}
I hope this article will help you with php programming.