Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload