0

I am passing a array value in url

&settings=[{"ID":"1","visibility":"not_selected"},{"ID":"56","visibility":"not_selected"},{"ID":"57","visibility":"not_selected"}]

And getting it in php using $settings=$_REQUEST['settings'] But using

                foreach(is_array($settings)  as $tag => $val) {

                    echo $combied_final[$tag]=$val;

                }   

Does not seems to working in this case . I want ID and Visibility separate . How can i do that ?

2 Answers 2

1

To access it as an array, make:

$settings=json_decode($_REQUEST['settings'], true);

and you better use $_GET, otherwise in $_REQUEST you will have also cookies.

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

2 Comments

@user1001176 "Didn't work", what do you mean? What did it return?
it works perfectly for me. Maybe you have some prepended file that adds slashes to $_REQUEST? then you must call stripslashes on $_REQUEST['settings']
0

First use json_decode to decode the values:

$list = json_decode($_REQUEST['settings']);
foreach($list as $item) {
    print $item->ID . $item->visibility;
}

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.