lundi 22 juin 2020

How to get value from input fields with two dimensional arrays in Laravel

I have input fields that are dynamically created it is like this:

<input type="text" name="attribute_value[][123]" class="form-control" required="">
<input type="text" name="attribute_value[][123]" class="form-control" required="">

<input type="text" name="attribute_value[][167]" class="form-control" required="">
<input type="text" name="attribute_value[][167]" class="form-control" required="">
<input type="text" name="attribute_value[][167]" class="form-control" required="">

<input type="text" name="attribute_value[][166]" class="form-control" required="">

Now i have 123, 167, 166 from my previous calculations, now i want to get all the fields with 163, 167, 166 for that i'm using following code, where key contains 123, 167, 166 as example it can contain more or any other value too :

 foreach ($request->input('attribute_value.*'.$key)  as $key => $value) {

                      print_r($key);
                      print_r($val);

                    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire