0

I have this url:

search.htm?postSearchForm=1&mediaTypes[3]=3

I need to get mediaTypes[3] with $_GET method

This code doesn't work:

$value = $_GET[mediaTypes[3]];
3
  • 1
    Do: print_r($_GET); and you will see the structure of your array. And I'm sure you will see the solution right away :) Commented May 15, 2016 at 14:40
  • $value = $_GET[mediaTypes][3]; Commented May 15, 2016 at 14:44
  • print $_GET and fetch your value from whatever index Commented May 15, 2016 at 14:49

1 Answer 1

2

You should write

 $value = $_GET['mediaTypes'][3];

And don't forget to filter the data, for example

 if (ctype_digit($_GET['mediaTypes'][3])) 
    $value = $_GET['mediaTypes'][3];
Sign up to request clarification or add additional context in comments.

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.