简体   繁体   中英

Php form isset with multiple brackets

I have a check box with a name of:

<input type='checkbox' name ='schedule[".$row['id']."][1]' />

I want to check if the check box was checked with the PHP isset(...) And I tried it as

isset($_POST['schedule[".$row['id']."][1]]);

But this didn't work. Any ideas that how It can works?

Try it like:

isset($_POST['schedule'][$row['id']][1])

Simply treat it as multi-D array in this case and edit particular index of schedule key.

After the submission of form the GLOBAL VARIABLES $_POST passes the data as string or int instead of original variables.

To check if checkbox was checked try this one:

$id = $row['id'];
if(isset($_POST['schedule'][$id][1])) {
     echo "hello world";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM