[eluser]Deep Arora[/eluser]
I need little php help to resolve the issue I am facing.
Here's my code:
Code:
foreach ($query->result() as $row)
{
$config = array(
'field' => $row->field_name,
'label' => $row->field_label,
'rules' => $row->field_rule
);
}
$rules_config = array($config);
return $rules_config;
In this, the $config array inside foreach loop ends up having only the last value in the row record. How can I keep adding records to this array so it forms a final array like this, after foreach is through;
Code:
$config = array(
'field' => $row->field_name,
'label' => $row->field_label,
'rules' => $row->field_rule
),
array(
'field' => $row->field_name,
'label' => $row->field_label,
'rules' => $row->field_rule
);