我在CodeIgniter中运行此代码:
for($j=0;$j<count($detials);$j++){
$newValues = array(
'Description' => $detials[$j]
);
}
目前它输出:
Array ( [Description] => Array ( [0] => this [1] => is [2] => a [3] => name ) )
我希望循环创建它:
$newValues = array(
'Description' => $detials[1]
'Description' => $detials[2]
'Description' => $detials[3]
);
我该怎么做?
答案 0 :(得分:1)
我不确定,但我认为您可能会尝试这样做:
for($j=0;$j<count($detials);$j++){
$newValues[] = array('Description' => $detials[$j]);
}
哪个会给你这个数组:
$newValues = array(
array('Description' => $detials[1]),
array('Description' => $detials[2]),
array('Description' => $detials[3])
);