title: Using PHP to check if an Element(ID) has a specific class assigned
body: <p>I want in my template.php (drupal theme) something like this:</p>
  
  <pre><code>$search_button ='search-button.png';
  if($('#page-wrapper').hasClass('blue-colour')) {
      $search_button ='search-button-blue.png';
  }
  else if ($('#page-wrapper').hasClass('green-colour')) {
      $search_button ='search-button-green.png';
  }
  $form['actions']['submit'] = array('#type' =&gt; 'image_button', '#src' =&gt; base_path() . path_to_theme() . '/images/'.$search_button);
  </code></pre>
  
  <p>Which doesn't work because it is jQuery. The problem is the syntax on this bit:</p>
  
  <blockquote>
    <p>if($('#page-wrapper').hasClass('blue-colour'))</p>
  </blockquote>
  
  <p>How can I do the same thing without using javascript or jQuery and only php and/or some Drupal function?</p>
  
  <p>I want to replace the icon for a search box based on a class set on a HTML element:</p>
  
  <pre><code>&lt;div id="page-wrapper" class="blue-colour"&gt;
  </code></pre>
  
  <p>In this case it would check that the class is 'blue-colour' and would set the correct blue icon on the variable ($search_button).</p>