mardi 25 avril 2017

How to get multiple values through one check box?

I would like to get an array from a checkbox with one [id] and one [date] for each record.

Here is my actual HTML / PHP :

<input type="checkbox" name="collection[][id]" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="collection[][date]" value="<?php echo date(Ymd); ?>" />

I get this :

Array
(
    [0] => Array
        (
            [id] => 544826
        )

    [1] => Array
        (
            [date] => 20170426
        )

    [2] => Array
        (
            [id] => 608555
        )

    [3] => Array
        (
            [date] => 20170426
        )
)

And I would like this :

Array
(
    [0] => Array
        (
            [id] => 544826
            [date] => 20170426
        )

    [1] => Array
        (
            [id] => 608555
            [date] => 20170426
        )
)

Please, how could I proceed ?




Aucun commentaire:

Enregistrer un commentaire