title: PHP - Adding string value to associative array
body: <p>This seem so simple, and yet I can't find a solution anywhere.</p>
  
  <p>What I want to do is add the <em>contents</em> (r-value) of a variable to an associative array instead of a <em>reference</em> to the variable.</p>
  
  <p>For example, I want this:</p>
  
  <pre><code>$myStr1 = "sometext";
  $myStr2 = "someothertext";
  
  $myArray = array(
      "key1"=&gt;$myStr1,
      "key2"=&gt;$myStr2
  );
  
  echo($myArray["key1"]);
  </code></pre>
  
  <p>To produce this:</p>
  
  <pre><code>"sometext"
  </code></pre>
  
  <p>Instead of this:</p>
  
  <pre><code>"1"        // why??
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The above works;  my bad.  Here's the <em>real</em> problem - my <code>$myStr1</code> variable isn't just assiged a string literal like in the above; it's created using the following syntax:</p>
  
  <pre><code>$myStr1 = "sometext" + anObject-&gt;intProperty + "moretext";
  </code></pre>
  
  <p>Basically I use the <code>+</code> to concatenate various types into a string.  Maybe <code>+</code> isn't doing what I think it's doing?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It was definitely the <code>+</code> operator.  I casted all non-strings to strings and used <code>.</code> to concatenate instead.</p>