Search code examples
phpurlparametersgetrequest

GET values from variables with [] in url


I have a URL like this

?custom[weight]=1&custom[weight2]=2

If i use echo $_GET[custom[weight]] then it doesn't work. How do i retrive this value?


Solution

  • You should access it with $_GET['custom']['weight'] and $_GET['custom']['weight2']

    You can check it with print_r($_GET) and you'll get something like,

    Array
    (
        [custom] => Array
            (
                [weight] => 1
                [weight2] => 2
            )
    )