Skip to content
Advertisement

How to pass the explode value in another foreach in PHP

I am getting all the data from the database and one of my column data is 1|3|6|8.

I am using explode to get the output.

Now, I have a checkbox list that I am getting from the database and I have to pass the explode value in the checkbox list to check the checkbox.

JavaScript

I know I have to use something like foreach and the <?php echo ($check['cid']==$e['value'] ? 'checked' : '');?>

Advertisement

Answer

Ok – I think that because the exploded string yields a simple array the inner foreach loop needs only to check if the current array member is equal to the cid field for the current record..

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement