Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从数组中获取数据无效_Php_Arrays_Codeigniter_Multidimensional Array - Fatal编程技术网

Php 从数组中获取数据无效

Php 从数组中获取数据无效,php,arrays,codeigniter,multidimensional-array,Php,Arrays,Codeigniter,Multidimensional Array,根据我的观点,我有以下表格: <table align="center" border="1"> <tr> <td>Identificação</td> <td>Conc, %</td> <td>Classificação 67/548/CEE</td> <td>Classificação 1272/2008 (CLP)</td> </tr>

根据我的观点,我有以下表格:

<table align="center" border="1">
<tr>
   <td>Identificação</td>
   <td>Conc, %</td>
   <td>Classificação 67/548/CEE</td>
   <td>Classificação 1272/2008 (CLP)</td>
</tr>
<tr>
   <td>
       <textarea rows="4" cols="30" name="componentes[0][identificacao]"></textarea>
   </td>
   <td>
       <textarea rows="4" cols="30" name="componentes[0][conc]"></textarea>
   </td>
   <td>
       <textarea rows="4" cols="30" name="componentes[0][classificacao_cee]"></textarea>
   </td>
   <td>
       <textarea rows="4" cols="30" name="componentes[0][classificacao_clp]"></textarea>
   </td>
</tr>
</table>

<div id="outro_curso"></div>
<p class="submit">
    <button id="novo_curso">Add Curso</button>
</p>
谁能帮我一点忙吗

编辑:

我忘了提到,我得到了错误:

为foreach()提供的参数无效

所以我不知道我的
foreach($this->input->post('components')作为$key=>$value){
是否正确,或者里面的行是否有问题

$componentes_post = $this->input->post('componentes');
if(is_array($componentes_post)&&!empty($componentes_post))
{
    foreach ($componentes_post as $key => $value)
    {
        $temp_componentes['identificacao']=$value['identificacao'];
        $temp_componentes['conc']=$value['conc'];
        $temp_componentes['classificacao_cee']=$value['classificacao_cee'];
        $temp_componentes['classificacao_clp']=$value['classificacao_clp'];
        $componentes[] = $temp_componentes;
    }
}
现在看

print_r($componentes);
你应该得到你需要的。
接下来,您将得到错误为foreach()提供的无效参数因为您在
foreach
上迭代的数组是空的,请使用
print\r($this->input->post('components'))

快速查看,确保该元素上有值,我猜您需要这个:
$components[$key]['IdentificateCao']=$value['IdentificateCao'];
我编辑了我的帖子Mudshark。现在我无法测试你的建议,因为我的foreach出现了一个错误。再好不过了。非常感谢hsuk,现在一切都很好。
print_r($componentes);