当前位置 : 主页 > 网络编程 > PHP >

php构造请求字符串.txt

来源:互联网 收集:自由互联 发布时间:2021-06-28
构造请求字符串.txt function buildQueryString($data) { $querystring = ''; if (is_array($data)) { // Change data in to postable data foreach ($data as $key = $val) { if (is_array($val)) { foreach ($val as $val2) { $querystring .= urlen
构造请求字符串.txt
function buildQueryString($data) {
        $querystring = '';
        if (is_array($data)) {
            // Change data in to postable data
            foreach ($data as $key => $val) {
                if (is_array($val)) {
                    foreach ($val as $val2) {
                        $querystring .= urlencode($key).'='.urlencode($val2).'&';
                    }
                } else {
                    $querystring .= urlencode($key).'='.urlencode($val).'&';
                }
            }
            $querystring = substr($querystring, 0, -1);
        } else {
            $querystring = $data;
        }
        return $querystring;
    }
//该片段来自于http://www.codesnippet.cn/detail/1407201513081.html
网友评论