Victor Kimura
asked on
PHP push array using array_push() to same array
Hi,
I have this bit of code:
I'm trying to use the array_push() and push another array with key=>value to the same array but when I use it the second array $aFeildsAppend it's pushed to $fields[0] rather than just $fields.
I tried this code too but it doesn't work:
How can I push the second array to the first one properly so it's all on the same array?
Thanks,
Victor
I have this bit of code:
$fields = array(
//set for all selections
'METHOD' => $METHOD,
'VERSION' => $VERSION,
'USER' => $USER,
'PWD' => $PWD,
'SIGNATURE' => $SIGNATURE,
'BUTTONCODE' => $BUTTONCODE,
'BUTTONSUBTYPE' => $BUTTONSUBTYPE,
'L_BUTTONVAR1' => $L_BUTTONVAR1,
'OPTION0NAME' => $OPTION0NAME
);
$aFieldsAppend = array (
//set in 3, 6, 12,
'L_BUTTONVAR2' => $L_BUTTONVAR2,
'BUTTONTYPE' => $BUTTONTYPE,
'L_OPTION0SELECT0' => $L_OPTION0SELECT0,
'OPTION0TYPE' => $OPTION0TYPE
);
array_push($fields, $aFieldsAppend);
I'm trying to use the array_push() and push another array with key=>value to the same array but when I use it the second array $aFeildsAppend it's pushed to $fields[0] rather than just $fields.
I tried this code too but it doesn't work:
array_push($fields, ('L_BUTTONVAR2' => $L_BUTTONVAR2,
'BUTTONTYPE' => $BUTTONTYPE,
'L_OPTION0SELECT0' => $L_OPTION0SELECT0,
'OPTION0TYPE' => $OPTION0TYPE));
How can I push the second array to the first one properly so it's all on the same array?
Thanks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 500 points for acbxyz's comment #a39828275
Assisted answer: 0 points for vkimura2007's comment #a39828306
for the following reason:
found a solution using array_merge() too. =)
Accepted answer: 500 points for acbxyz's comment #a39828275
Assisted answer: 0 points for vkimura2007's comment #a39828306
for the following reason:
found a solution using array_merge() too. =)
Ermm did you miss the link in my comment.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Cathal, Oh, so sorry! I did miss it! Sorry. =( Can I award half the points to you still? Will try. Sorry, Cathal.
ASKER
Thanks @acbxyz. I didn't think of that solution. Simple.
But I found that I could do this too:
Open in new window