A-A+
php 数据包的分组与合并 parse_str与http_build_query的使用
php 数据包的分组与合并 parse_str与http_build_query的使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php //parse_str与http_build_query的使用 //使用parse_str将url字符串转变为key=>value的数组 $str = "tn=monline_dg&ie=utf-8&bs=httpbuildurl&f=3&rsv_bp=1&wd=php+buildquery&rsv_sug3=17&rsv_sug4=330&rsv_sug1=16&oq=php+build&rsv_sug2=0&rsp=0&inputT=8922"; parse_str($str,$arr); var_export($arr); /* 输出: array ( 'tn' => 'monline_dg', 'ie' => 'utf-8', 'bs' => 'httpbuildurl', 'f' => '3', 'rsv_bp' => '1', 'wd' => 'php buildquery', 'rsv_sug3' => '17', 'rsv_sug4' => '330', 'rsv_sug1' => '16', 'oq' => 'php build', 'rsv_sug2' => '0', 'rsp' => '0', 'inputT' => '8922', ) */ //使用http_build_query将key=>value的数组转变为url字符串 $url = http_build_query($arr); echo($url); //输出:tn=monline_dg&ie=utf-8&bs=httpbuildurl&f=3&rsv_bp=1&wd=php+buildquery&rsv_sug3=17&rsv_sug4=330&rsv_sug1=16&oq=php+build&rsv_sug2=0&rsp=0&inputT=8922 ?> |
文章来源:http://blog.csdn.net/e421083458/article/details/23616667
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏