title: Forcing a SimpleXML Object to a string, regardless of context
body: <p>Let's say I have some XML like this</p>
  
  <pre><code>&lt;channel&gt;
    &lt;item&gt;
      &lt;title&gt;This is title 1&lt;/title&gt;
    &lt;/item&gt;
  &lt;/channel&gt;
  </code></pre>
  
  <p>The code below does what I want in that it outputs the title as a string</p>
  
  <pre><code>$xml = simplexml_load_string($xmlstring);
  echo $xml-&gt;channel-&gt;item-&gt;title;
  </code></pre>
  
  <p>Here's my problem.  The code below doesn't treat the title as a string in that context so I end up with a SimpleXML object in the array instead of a string.</p>
  
  <pre><code>$foo = array( $xml-&gt;channel-&gt;item-&gt;title );
  </code></pre>
  
  <p>I've been working around it like this</p>
  
  <pre><code>$foo = array( sprintf("%s",$xml-&gt;channel-&gt;item-&gt;title) );
  </code></pre>
  
  <p>but that seems ugly.</p>
  
  <p><strong>What's the best way to force a SimpleXML object to a string, regardless of context?</strong></p>