Return key of an Array from given value

Posted 10 months ago by nizam0786

Hi guys,

I am a bit stuck on a function I am writing up.

I am posting a form which contains a hidden id input, a input for serial number and a checkbox which is clicked if the object is printed or not.

Form values

 

input name="serials[]" type="text" value="633597 0107 8137" size="21"

input name="passesPrinted[]" type="checkbox" value="{{$pass->id}}"

input class="hidden" name="passes[]" type="text" value="{{$pass->id}}" readonly

So after the form is posted I need to update only the object which has the checkbox selected.

The way I am trying to do that is searching for the value of checkbox in the passesPrinted array and return the key so I can just loop through and save the values.

However, I am not sure how to get the key etc...

Thanks in advance.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.