Php 如何将字符串打印到数组中

Php 如何将字符串打印到数组中,php,mysql,arrays,oop,pdo,Php,Mysql,Arrays,Oop,Pdo,我试图将字符串打印到数组 表格将通过数组提交。表单的数量是未知的,因为用户可以在需要时添加额外的输入(订单系统) 要运行表单的验证,它需要如下所示: $toxValidate = new toxValidate(); $toxValidation = $toxValidate->check('$_POST', array( 'part1' => array('required' => TRUE), 'part2' => array(

我试图将
字符串
打印到
数组

表格将通过数组提交。表单的数量是未知的,因为用户可以在需要时添加额外的输入(订单系统)

要运行表单的
验证
,它需要如下所示:

$toxValidate = new toxValidate();
    $toxValidation = $toxValidate->check('$_POST', array(
        'part1' => array('required' => TRUE),
        'part2' => array('required' => TRUE),
        'part3' => array('required' => TRUE),
        'part4' => array('required' => TRUE),
        'part5' => array('required' => TRUE)
    ));
但是因为我们不知道它将有多少个
输入,所以每个输入都需要一行:
'part1'=>数组('required'=>TRUE),

这就是我所尝试的:

for($i=0; $i<count($part); $i++){
        $parts .= "part".$i." => array('required' => true)";
        $t0x = $t0x + 1;
        if($t0x < count($part)){
            $parts .= ', ';
        }
    }
这正是需要打印的内容:

$toxValidation = $toxValidate->check($_POST, array(
#HERE#
));
我尝试了打印和回声,但我认为这是行不通的

如何将
$parts
打印到阵列中

更新

HTML格式:

<div id="form">
                            <p class="order">
                            <label  style="margin-left:20px;">Partnumber:</label><br />
                            <input type="text"  style="margin-left:20px;" class="text medium" id="part" name="part[]" placeholder="SP partnumber" />
                            </p>
                            <p class="order" >
                            <label style="margin-left:20px">Qty</label><br>
                            <input type="text" id="qty" name="qty[]" style="margin-left:20px;" class="text small" placeholder="Qty" />
                            <p class="order">
                            <label style="margin-left:20px">Price</label><br>
                            <input type="text"  style="margin-left:20px;" class="text small" id="price" placeholder="Price" tabindex="-1" readonly /><br>
                          </p>

                        </div><p>

显示使用HTML和jQuery源代码更新的HTMLPost示例。类似于:
$options=[];对于($i=0;$itrue);}$toxValidation=$toxValidate->check('$\u POST',$options)?@Cyclonecode我在底部的问题中回答了你的评论。
<div id="form">
                            <p class="order">
                            <label  style="margin-left:20px;">Partnumber:</label><br />
                            <input type="text"  style="margin-left:20px;" class="text medium" id="part" name="part[]" placeholder="SP partnumber" />
                            </p>
                            <p class="order" >
                            <label style="margin-left:20px">Qty</label><br>
                            <input type="text" id="qty" name="qty[]" style="margin-left:20px;" class="text small" placeholder="Qty" />
                            <p class="order">
                            <label style="margin-left:20px">Price</label><br>
                            <input type="text"  style="margin-left:20px;" class="text small" id="price" placeholder="Price" tabindex="-1" readonly /><br>
                          </p>

                        </div><p>
    $('#addpart').click(function(){
  var loop = $('#loop').val();
  var html;
  html = '<p>';
  html += '<input type="text" name="part[]" style="margin-left:20px;" class="text medium" id="part" placeholder="SP partnumber" />';
  html += '<input type="text" name="qty[]" style="margin-left:20px;" class="text small" placeholder="Qty" />';
  html += '<input type="text" style="margin-left:20px;" class="text small" id="price" placeholder="Price" tabindex="-1" readonly />';
  html += '</p>';
  for (i = 0; i < loop; i++) {
    $("#form").append(html);
}

});
$toxValidation = $toxValidate->check('$_POST', array(
            'po'            => array('required' => TRUE),
            'date'      => array('required' => TRUE),
            'bo'            => array('required' => TRUE),
            'remarks'   => array('required' => TRUE),
#PARTS HERE#
    ));