php - How to create an Array from the checked boxesGet the solution ↓↓↓
I have 1000 checkboxes of object fields and I want to create an Array from all the fields that I check after submitting using PHP can you tell me how to do it?
well if you name your checkbox like this, you already have an array:
<input name="mycheckbox" value="1"> hello1 <input name="mycheckbox" value="2"> hello2 <input name="mycheckbox" value="3"> hello3
in PHP you will get:
print_t($_REQUEST['mycheckbox']); /* [ 0 => '1', 0 => '2', 0 => '3' ] */
<input type="checkbox" name="somename" value="somevalue"> if you need an array with numerical indices
<input type="checkbox" name="someobject[property]" value="somevalue"> if you are looking for an associative array
People are also looking for solutions of the problem: please make sure the php redis extension is installed and enabled.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.