How can I deal with this error:
Warning:
in_array()expects parameter 2 to be array, string given in C:\xampp\htdocs\php\index.php
My code is:
if (!isset($_GET['jenis'])) {
$jenis = "";
} else {
$jenis = $_GET['jenis'];
}
<li><input type="checkbox" onclick="jeniss();" name="jenis[]" value="11" <?php if (in_array("11",$jenis)) { echo "checked"; } ?> > <a> 11 </a> </li>
<li><input type="checkbox" onclick="jeniss();" name="jenis[]" value="12" <?php if (in_array("12",$jenis)) { echo "checked"; } ?> > <a> 12 </a> </li>
<li><input type="checkbox" onclick="jeniss();" name="jenis[]" value="13" <?php if (in_array("13",$jenis)) { echo "checked"; } ?> > <a> 13 </a> </li>
Note: the error at HTML input type when the page has not posted anything yet.
$jenisis a string, so it's kind of hard to do an array search on it.$jenis = "";to$jenis = [];