I have a form that has multiple checkboxes and when I do print_r to see the values that are posted they come is in the following format:

[group] => Array ( [22] => 22 [44] => 44 ) 

etc. Normally I run a loop to insert these values into a db, however when I use this form for editing values I can only edit one entry at a time. So how do I convert this array into a simple value when I submit a single checkbox?

[group] => Array ( [22] => 22 ) 

something like $_POST['group'] = 22;

long day, can't think straight...

    would be good to see your form
    from where these POST values come
    🙂 🙂

      So you just want to replace the value with the first element in the array? Sounds like [man]array_shift/man is the easiest way...

      $group = array_shift($_POST['group']);

        why is your Key & Value the same ?? is that by design?

        If not, using group[] as your field name will save them as $POST['group'][0], $POST['group'][1], etc.....

        or when you do your insert, use can use a foreach() or while(list... loop....

          Write a Reply...