Giter Club home page Giter Club logo

Comments (2)

mtdowling avatar mtdowling commented on May 1, 2024

This is the expected behavior of parse_query, and it's documented as such on the function you linked to.

On Nov 10, 2015, at 4:26 AM, Eden Tsai [email protected] wrote:

I found a issue about \GuzzleHttp\Psr7\parse_query() not works when a query string contains an array.

For example:

// Generate a query string
$query = [
'foo' => ['item1', 'item2', 'item3'],
];
$queryString = http_build_query($query, null, '&', PHP_QUERY_RFC3986);

// @see http://php.net/manual/en/function.parse-str.php
$parseStrResult = [];
parse_str($queryString, $parseStrResult);

// Show the different between parse_str() and parse_query()
$queries = [
'query_string' => $queryString,
'origin_query' => $originQuery,
'parse_str' => $parseStrResult,
'parse_query' => \GuzzleHttp\Psr7\parse_query($queryString),
'parse_query_with_rfc3986' => \GuzzleHttp\Psr7\parse_query($queryString, PHP_QUERY_RFC3986),
'parse_query_with_rfc1738' => \GuzzleHttp\Psr7\parse_query($queryString, PHP_QUERY_RFC1738),
];
print_r($queries);
the example output:

Array [12/21256]
(
[query_string] => foo%5B0%5D=item1&foo%5B1%5D=item2&foo%5B2%5D=item3
[origin_query] => Array
(
[foo] => Array
(
[0] => item1
[1] => item2
[2] => item3
)

    )

[parse_str] => Array
    (
        [foo] => Array
            (
                [0] => item1
                [1] => item2
                [2] => item3
            )

    )

[parse_query] => Array
    (
        [foo[0]] => item1
        [foo[1]] => item2
        [foo[2]] => item3
    )

[parse_query_with_rfc3986] => Array
    (
        [foo[0]] => item1
        [foo[1]] => item2
        [foo[2]] => item3
    )

[parse_query_with_rfc1738] => Array
    (
        [foo[0]] => item1
        [foo[1]] => item2
        [foo[2]] => item3
    )

)
β€”
Reply to this email directly or view it on GitHub.

from psr7.

edentsai avatar edentsai commented on May 1, 2024

Oops...i miss the document on the function, sorry about that.

from psr7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.