如何在PHP中将数据动态添加到数组中

I want to add new data to an array dynamically using HTML and PHP

Here is my code:

<form action="" method="">
<input type="text" name="name">
<input type="submit" name="send">
</form>

   <?php
   if(isset($_POST['send']))
   {
     $name = $_POST['name'];
     for($=1;$i<2;$++)
     {
     $name = array($name);
     $names = array_push($names,$name);
     }
     print_r($names);
   }
  ?>`

Does anyone have a better way?

查看全部
dongxia9620
dongxia9620
2013/09/05 14:11
  • for-loop
  • php
  • dynamic
  • arrays
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复