PHP function to build query string from array - not http build query

前端 未结 5 2000
终归单人心
终归单人心 2021-01-19 10:49

Hello I know all about http://www.php.net/manual/en/function.http-build-query.php to do this however I have a little problem.

It \"handly\" turns boolean values into

5条回答
  •  悲&欢浪女
    2021-01-19 11:44

    Loop through each variable of the query string ($qs) and if bool true or false, then change value to string.

    foreach($qs as $key=>$q) {
        if($q === true) $qs[$key] = 'true';
        elseif($q === false) $qs[$key] = 'false';
    }
    

    Then you can use the http_build_query()

提交回复
热议问题