How to pass an array via $_GET in php?

后端 未结 4 1615
眼角桃花
眼角桃花 2020-11-29 03:35

How can I pass one or more variables of type array to another page via $_GET?

I always passed variable values in the form ?a=1&b=2&c=3

W

4条回答
  •  粉色の甜心
    2020-11-29 04:05

    You can pass an associative array to http_build_query() and append the resulting string as the query string to the URL. The array will automatically be parsed by PHP so $_GET on the receiving page will contain an array.

    Example

    $query_str = http_build_query(array(
        'a' => array(1, 2, 3)
    ));
    

提交回复
热议问题