Returns value of an array dynamically

1

I have an array

$teste = [1,2,3,4];

<Input type="text" value ="teste[0]" />

//retorna "1"

How can I get all the array values in the inputs?

    
asked by anonymous 24.09.2018 / 21:33

1 answer

3

Loop your array by adding a input to each item:

<?php
  $teste = [1,2,3,4];

  foreach ($teste as $t) {
    echo "<input type='text' value='$t'>";
  }
?>

ideone result

    
24.09.2018 / 22:13