title: Cast to array VS is_array()
body: <p>Does anyone know of any issues, performance or other, that can occur by casting a variable to an array instead checking it first?</p>
  
  <pre><code>// $v could be a array or string
  $v = array('1','2','3'); 
  </code></pre>
  
  <p>OR </p>
  
  <pre><code>$v = '1';
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>if (is_array($v)) foreach ($v as $value) {/* do this */} else {/* do this */}
  </code></pre>
  
  <p>I've started to use:</p>
  
  <pre><code>foreach((array) $v as $value) {
      // do this
  }
  </code></pre>
  
  <p>It stops the repetition of code quite a bit - but performance is on my mind, not ugly code.</p>
  
  <p>Also, does anyone know how php handles casting an array to an array? No errors are thrown but does the php engine check if it's a array, then return a result before doing the cast process?</p>