I have an object with several properties that creates a multi dimensional array. I'm trying to figure out how to create a new array that combines two seperate objects into one. It would go from this:
array(
object_1(
'id' => '1',
'name' => 'joe'
etc....),
object_2(
'id' => '2',
'name' => 'jessica',
etc....)
object_3(
'id' => '3',
'name' => 'tim',
etc....)
object_4(
'id' => '4',
'name' => 'tammy',
etc....)
);
And become:
array(
object_1(
'id' => '1',
'name' => 'joe',
etc...
'id2' = > '2',
'name2' => 'jessica',
etc...)
object_2(
'id' => '3',
'name' => 'tim',
etc...
'id2' = > '4',
'name2' => 'tammy',
etc...)
So, I need to combine the data from alternating elements, and also change the key in all the second objects so it doesn't match the first. Make sense? Sorry if it doesn't, I'll try to clarify if you need!
Thanks for any help....
EDIT: first two stdclass objects according to print_r:
[results] => Array
(
[0] => stdClass Object
(
[email] => [email protected]
[message] => Create another test
[image] => 138.png
[fid] => 53
)
[1] => stdClass Object
(
[email] => [email protected]
[message] => none
[image] => 330.jpg
[fid] => 52
)
and I want it to become:
[results] => Array
(
[0] => stdClass Object
(
[email] => [email protected]
[message] => Create another test
[image] => 138.png
[fid] => 53
[email2] => [email protected]
[message2] => none
[image2] => 330.jpg
[fid2] => 52
)
Does that clarify?
forloop should do it, so what have you tried?