This might seem super easy but to me its not, I have the following method:
public function addRadioButtonTab($groupName, $radioButtonTab)
{
$radioButtonTab = new RadioButtonTab($radioButtonTab);
$this->radioButtonTabs[][$groupName] = $groupName;
$this->radioButtonTabs[][] = $radioButtonTab;
}
I want to push the $radioButtonTab
into the same array that contains the key: $groupName
.
Right now I get two separate arrays, one with the key=>value
and one with the object.
instead of looping and doing complex things try this:
public function addRadioButtonTab($groupName, $radioButtonTab)
{
$radioButtonTab = new RadioButtonTab($radioButtonTab);
$this->radioButtonTabs[][$groupName] = array($groupName, $radioButtonTab);
}
You should make an array of the values you want first, then append that to $this->radioButtonTabs
.
public function addRadioButtonTab($groupName, $radioButtonTab)
{
$radioButtonTab = new RadioButtonTab($radioButtonTab);
// Just append arrays into the main array
$this->radioButtonTabs[] = array('group_name' => $groupName, $radioButtonTab);
// Or if you want your array to use `$groupName` as a key
$this->radioButtonTabs[$groupName] = array('group_name' => $groupName, $radioButtonTab)
}