我有以下数组
<?php
echo "<pre>";
print_r($row);
?>
Array
(
[0] => Array
(
[contact] => ugin
)
[1] => Array
(
[contact] => gsGR
)
[2] => Array
(
[addtnlcontact] => ghjey
)
)
Array
(
[0] => Array
(
[relation] => uncle
)
[1] => Array
(
[relation] => mrsyjsrky
)
[2] => Array
(
[relation] => cghjrtdj
)
)
如果我打印echo "<pre>"; print_r($row[0]);
我有以下数组
Array
(
[contact] => ugin
)
Array
(
[relation] => uncle
)
我需要上面的$ row [0] =&gt; contact =&gt;乌金 relation =&gt;叔叔
尝试下面的代码:
$addcont[] = $this->input->post(sheepItForm1_addtnlcontact);
$this->conditionloop($addcont[0],'contact');
$relation[] = $this->input->post(sheepItForm1_relationship);
$this->conditionloop($relation[0],'relation');
public function conditionloop($val,$name)
{
foreach($val as $key => $res)
{
if(!empty($res)) {
$row[$key][$name] = $res;
//echo "<pre>"; print_r($row[$key]);
}
}
echo "<pre>"; print_r($row[0]);
}
请帮助解决这个问题