I have an html code as shown below. The following html code displays list of checkboxes as shown in the screenshot below the code.
<?php
$output['toggle_multi_tiles']=$_POST['toggle_multi_tiles'];
$output['episode_status']=$_POST['episode_status'];
$fp = fopen('../feeds/ptp-ess_landing.json', 'w');
fwrite($fp, json_encode($output));
fclose($fp);
logActivity();
if(file_exists('../feeds/ptp-ess_landing.json')){
$data = json_decode(file_get_contents('../feeds/ptp-ess_landing.json'));
}
?>
<?php if($data){
?>
<fieldset style="background-color:darkseagreen;">
<input type="checkbox" id="ptp" value="0" name="toggle_multi_tiles[]" <?php if($data->{"toggle_multi_tiles[]"}==0){echo
'checked';}?>>
<label for="toggle-multi-off">PTP</label>
<input type="checkbox" id="l'e" value="1" name="toggle_multi_tiles[]" <?php if($data->{"toggle_multi_tiles[]"}==1){echo
'checked';}?>>
<label for="position-one">L'E</label>
<div>
<button type="submit">Save</button> //Line A
</div>
</fieldset>
<?php } ?>
On hitting save button at Line A after selecting the first 2 check-boxes from the screenshot above , everything get save in JSON as shown below:
{"toggle_multi_tiles":["0","1"]}
Problem Statement:
The issue which I am having right now is after saving the 2 check-boxes, the only check-box which display on page refresh is the 1st one (not both).
($data->{"toggle_multi_tiles[]"}==0) from the html code is reading from JSON.
($data->{"toggle_multi_tiles[]"}==1) from the html code is reading from JSON.


$data->{"toggle_multi_tiles[]"}==1does?1. Rubber duck debugging is usually a very good method.{"toggle_multi_tiles":["0","1"]}? In browser's console or in PHP?