CONTEXT
I am developing a profile creation form with a checkbox group that implodes and inserts the comma-separated array into a MySQL table ($profile_table).
<input type="checkbox" name="check_group[]" value="Foo" /> Foo<br />
<input type="checkbox" name="check_group[]" value="Bar" /> Bar<br />
<input type="checkbox" name="check_group[]" value="Baz" /> Baz<br />
$insert_array = implode(", ", $_POST['check_group']);
If all checkboxes are checked, the array looks like: "Foo, Bar, Baz"
$insert_profile_query = "INSERT INTO profile_table
(check_group_field)VALUES ('".$insert_array."')";
$profile_query_qs = db_query($insert_profile_query);
The code above works.
I need an edit profile page where the checkbox group is pre-filled using the array that was created above and inserted in the MySQL $profile_table.
Using the "Foo" checkbox as an example, I believe the answer uses an in_array conditional and is something close to:
<input type="checkbox" name="check_group[]" value="Foo"
<? $my_array = array(explode(", ", $profile_table['check_group_field']));
if (in_array("Foo", $my_array)) {echo 'checked="checked"';}?> /> Foo<br />
QUESTION
Specifically, what is the best function to get the array out of the MySQL $profile_table.check_group_field so I can use it in the in_array conditional as $my_array to pre-fill the checkboxes in the checkbox group? Do I need to explode the array first?
EXAMPLE RESOURCES
Here is an example of the many resources I am referencing; but, I am not finding the specific issue I need to address:
https://www.php.net/in_array http://www.sitepoint.com/forums/showthread.php?577188-Retrieving-A-Checkbox-Array-from-MySql Populate checkbox from array
Thanks in advance!