检索和循环当我点击按钮,我产生了一些输入自定义字段属性那样:输入自定义属性值:在PHP
<input type='text' name='field["+ i++ +"]' value='' data-kind='title' />
<input type='text' name='field["+ i++ +"]' value='' data-kind='video' />
<input type='text' name='field["+ i++ +"]' value='' data-kind='text' />
我检索与PHP中的foreach循环的“名”值:
$result = array_combine($num, $records);
foreach ($result as $rank => $content)
{
$data = array(
'content' => $content,
'post_id' => $post_id,
'rank' => $rank,
'type' => $this->input->post('field_type') // HERE
);
echo '<pre>';print_r($data);echo '</pre>';
}
为了得到 '型' 我做的这是由该给出$this->input->post('field_type');
:
var field_type = $(":input[data-kind]").attr('data-kind');
$("#field_type").val(field_type' ');
和:
echo '<input type="hidden" id="field_type" name="field_type" value="" />';
但它只返回我的最后一个“数据实物的价值不是每个人:/
现在我只需要循环为每个输入字段”数据实物的价值在我的foreach循环检索它们
任何帮助将是非常非常感谢!
非常感谢您的回答,它帮了我很多!但现在我怎么能在“类型”数据添加的结果在我目前的foreach:
$result = array_combine($num, $records);
foreach ($result as $rank => $content)
{
$data = array(
'content' => $content,
'post_id' => $post_id,
'rank' => $rank,
'type' => // HERE I NEED EACH ATTRIBUTE VALUE
);
echo '<pre>';print_r($data);echo '</pre>';
}