0

我需要一些帮助。

我有一个这样的数组结构。

$data = array(
        'id_packet' => NULL,
        'name_packet' => NULL,
        'number_of_users' => NULL,
        'number_of_blogs' => NULL,
        'number_of_accounts' => NULL,
        'price' => NULL,
        'period' => NULL,
        'status' => 1,
);

'number_of_users' => NULL, 'number_of_blogs' => NULL, 'number_of_accounts' => NULL,以下搜索在数据库中的结果在哪里:

$n=1;
foreach ($list_component as $dt) { 
        $comp[$n] = $dt->name_comp;
        echo "'".$comp[$n]."' => NULL,";
        $n++;
}

并成功显示了预期的结果。

我想问一下, 'number_of_users' => NULL, 'number_of_blogs' => NULL, 'number_of_accounts' => NULL,上面的$data数组怎么包含?

我一直在寻找一些参考,但没有找到任何参考。也许你们中的一个人可以提供帮助或有任何想法?谢谢。

框架:Phalcon

4

2 回答 2

0

尝试这个:

foreach ($data as $key => $value){
    if (empty($value)){
        $disp = 'NULL';
    } else {
        $disp = $value;
    }
    echo "'".$key."' = ".$disp.",\n";
}
于 2013-07-18T08:54:58.367 回答
0

你可以做这样的事情

$data = array(
        'id_packet' => NULL,
        'price' => NULL,
        'period' => NULL,
        'status' => 1,
);
$n=1;
foreach ($list_component as $dt) { 
        $comp[$n] = $dt->name_comp;
        $data[$comp[$n]]= NULL;
        $n++;
}
于 2013-07-18T07:57:39.267 回答