How to get same fields in POST
<pre><code>&lt;form action="form.php" id="form"&gt;
&lt;input type="text" name="name_1"&gt;&lt;input type="text" name="city_1"&gt;&lt;input type="text" name="country_1"&gt;
&lt;input type="text" name="name_2"&gt;&lt;input type="text" name="city_2"&gt;&lt;input type="text" name="country_2"&gt;
&lt;input type="text" name="name_3"&gt;&lt;input type="text" name="city_3"&gt;&lt;input type="text" name="country_3"&gt;

    &lt;input type="submit"&gt;
&lt;/form&gt;
</code></pre>

<p>How is the best method for get this data in form.php file? This is generated with jQuery. Can be 3 (as now) or 30.</p>

<p>In form.php i have:</p>

<pre><code>$data = new Data();
$data-&gt;name = $_POST['name_1'];
$data-&gt;city = $_POST['city_1'];
$data-&gt;country = $_POST['country_1'];
$data-&gt;save();
$data = new Data();
$data-&gt;name = $_POST['name_2'];
$data-&gt;city = $_POST['city_2'];
$data-&gt;country = $_POST['country_2'];
$data-&gt;save();
$data = new Data();
$data-&gt;name = $_POST['name_3'];
$data-&gt;city = $_POST['city_3'];
$data-&gt;country = $_POST['country_3'];
$data-&gt;save();
</code></pre>

<p>But if there is over 3? I would like use <strong>foreach</strong>, but how? How can i generated input or get this data?</p>
