Vectors Input in Laravel

0

I need to collect all the inputs for 2 reasons:

1º Saber cuantos había.
2º Saber cual fue pulsado.

The problem is that it returns only one position

In the view:

for ($i = 0; $i < 4; $i++) {
                    echo "  <input type='submit' name='btngolpeado[]' 
                    value='¿ Aquí ? '> ";
                }

On the controller:

 $posicion = $request->get('btngolpeado');

         var_dump($posicion);

          for($i=0;$i<count($posicion);$i++){
              if($posicion[$i] != null){
                  echo "posicion".$i."fue golpeada";
              }
              echo "pasada".$i;
          }

Press the button that you press, always bring out the same: The var_dump and the execution take:

array(1) { [0]=> string(11) "¿ Aquí ? " } posicion0fue golpeadapasada0
    
asked by EduBw 13.11.2017 в 21:43
source

1 answer

0

First of all, your driver has to import

use Illuminate\Http\Request;

Well, now in your function you call it with

public function ejemplo(Request $request, $opcional)
    {

and now use it in the function

 foreach ($request->btngolpeado as $id => $valor) {
      echo $id . " => " . $valor . "<br>";
}
    
answered by 16.11.2017 в 10:44