I need to add key and value to an existing array and don't seem to be able to get it together.
My existing array when printed looks like this:
Array
(
[0] => stdClass Object
(
[id] => 787
[name] => Steve
[surname] => Ryan
[email] => Steve@hotmail.com
)
[1] => stdClass Object
(
[id] => 1057
[name] => Peter
[surname] => Smith
[email] => Peter.Smith@yahoo.com
)
[2] => stdClass Object
(
[id] => 1058
[name] => Chris
[surname] => Gill
[email] => chrisgill@gmail.com
)
)
I need to add a few details to this array on the fly from a string
that looks like this:
Topher:Topher1234@mac.com
Elvis:elvispresley@gmail.com
Marilyn:marilyn.monroe@hotmail.com
Each entry is seperated by a new line
and the name and email address is seperated by a :
So in the end my array would look like this:
Array
(
[0] => stdClass Object
(
[id] => 787
[name] => Steve
[surname] => Ryan
[email] => Steve@hotmail.com
)
[1] => stdClass Object
(
[id] => 1057
[name] => Peter
[surname] => Smith
[email] => Peter.Smith@yahoo.com
)
[2] => stdClass Object
(
[id] => 1058
[name] => Chris
[surname] => James
[email] => chrisjames@gmail.com
)
[3] => stdClass Object
(
[id] =>
[name] => Topher
[surname] =>
[email] => Topher1234@mac.com
)
[4] => stdClass Object
(
[id] =>
[name] => Elvis
[surname] =>
[email] => elvispresley@gmail.com
)
[5] => stdClass Object
(
[id] =>
[name] => Marilyn
[surname] =>
[email] => marilyn.monroe@hotmail.com
)
)
I looked at array_push but couldn't work it out.
Any help with this is very much sppreciated.
C