当前输出为:3个数组
Array ( [pf_id] => 5 [pf_title] => Gender [pf_icon] => [pf_key] => gender )
Array ( [pf_id] => 6 [pf_title] => Location [pf_icon] => [pf_key] => location )
Array ( [pf_id] => 7 [pf_title] => Interests [pf_icon] => [pf_key] => interests )
结果必须是这样的: 1 个数组,包括每个 pf_id 的 1 个子数组
Array (
5 => array ([pf_title] => Gender [pf_icon] => [pf_key] => gender)
6 => array ([pf_title] => Location [pf_icon] => [pf_key] => location)
7 => array ([pf_title] => Interests [pf_icon] => [pf_key] => interests)
)
获取数据的代码:
$cfields = array();
$this->DB->build( array(
'select' => 'pf_d.pf_id, pf_d.pf_title, pf_d.pf_icon, pf_d.pf_key',
'from' => array( 'pfields_data' => 'pf_d' ),
'where' => 'pf_d.pf_id = 5 or pf_d.pf_id = 6 or pf_d.pf_id = 7',
) );
// if ($this->settings['b_multiplayer_f_id'] && in_array( $this->request['f'], explode(',', $this->settings['b_multiplayer_f_id'] ) ) ) {
print $this->DB->fetchSqlString();
// }
$this->DB->execute();
while ( $row = $this->DB->fetch() ) {
// array correction starts please help!!
# $extract = array();
# $extract = implode/explode??
# $extract[] = $row['pf_id'].' => '.array( 'pf_title' => $row['pf_title'], 'pf_icon' => $row['pf_icon'], 'pf_key' => $row['pf_key']);
// array correction finish
$cfields[] = $extract;
print_r($row);
}
我正在使用 invisionpower 板(我是客户,但不需要他们的回应......来解决)
以及如何将数据数组(n => array())提取到模板中?示例代码:
<foreach loop="$cfields as $key=>$value"> {$value[pf_title]} => {$this->memberData['field_'.$key]} </foreach>
是正确的?