0

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?

1
  • 1
    You access it like $_GET['custom']['weight'] this returns 1 Or $_GET['custom']['weight2'] will return 2 Commented Oct 21, 2019 at 15:15

2 Answers 2

1

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
        )
)

Sign up to request clarification or add additional context in comments.

Comments

1

In the provided example $_GET becomes multidimensional and custom is an index with the array so you want.

foreach( $_GET['custom'] as $index => $value) { 
     echo $index . ' has the value of ' .  $value . PHP_EOL; 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.