title: php strlen range function
body: <p>Im trying to write an if function which checks the width of an image, and then apply a css class.</p>
  
  <p>I want the function to work like this</p>
  
  <p>if image is in an range from 150px to 189px, apply css class "span-4"</p>
  
  <p>190px to 229px: css class "span-5"</p>
  
  <p>230px to 269px: css class "span-6"</p>
  
  <p>I have tried like this:</p>
  
  <pre><code>list($width, $height, $type, $attr) = getimagesize($article_image);
  
  if(strlen($width) &lt; 189 &amp;&amp; strlen($width) &gt; 150) { $cssClass = "span-4"; }
  if(strlen($width) &lt; 229 &amp;&amp; strlen($width) &gt; 190) { $cssClass = "span-5"; }
  if(strlen($width) &lt; 269 &amp;&amp; strlen($width) &gt; 230) { $cssClass = "span-6"; }
  </code></pre>
  
  <p>That does not work. Do anyone see what Im doing wrong?</p>
  
  <p><em>Edit: Added the function to explaine where Im getteing the $width variable from</em></p>