I need some help.
I have an array structure like this.
$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,
);
Where 'number_of_users' => NULL, 'number_of_blogs' => NULL, 'number_of_accounts' => NULL,
are the results of the following search in a database:
$n=1;
foreach ($list_component as $dt) {
$comp[$n] = $dt->name_comp;
echo "'".$comp[$n]."' => NULL,";
$n++;
}
and it has successfully displayed the expected results.
I want to ask, how to include 'number_of_users' => NULL, 'number_of_blogs' => NULL, 'number_of_accounts' => NULL,
in the $data array above?
I've been looking for some reference, but have not managed to find any. Perhaps one of you can help or have any idea? Thanks.
Framework: Phalcon
You can do something like this
$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++;
}
Try this:
foreach ($data as $key => $value){
if (empty($value)){
$disp = 'NULL';
} else {
$disp = $value;
}
echo "'".$key."' = ".$disp.",
";
}