better way to check if in array and then in array
<p>I am adding the following code to check whether a checkbox should be checked or not:</p>

<pre><code>is_array($current_color_id_array) ? in_array('1', $current_color_id_array) : ''
</code></pre>

<p>I'm just wondering if there is nicer/more concise way to do it perhaps?</p>

<p>Edit: Sorry I was not clear enough, and actually my code was wrong..</p>

<p>This is supposed to check if $current_color_id_array is an array because apparently if I don't check it will give me the error Warning: in_array() expects parameter 2 to be array</p>

<p>and it should also check if the value is in the array to mark the checkbox as checked. </p>

<p>this is all part of a checkbox function: </p>

<pre><code>function tep_draw_checkbox_field($name, $value = '', $checked = false, $compare = '') {
    return tep_draw_selection_field($name, 'checkbox', $value, $checked, $compare);
  }
</code></pre>

<p>it is the third parameter. So if I can reask this  I would say is there a better way of writing: </p>

<pre><code>tep_draw_checkbox_field('color_id[]', '1', (is_array($current_color_id_array) &amp;&amp; in_array('1', $current_color_id_array)))
</code></pre>

<p>and just in case, this is how the array is made:</p>

<pre><code>$color_id_query = tep_db_query("select color_id from " . TABLE_PRODUCTS_TO_COLORS . " where products_id = '" . (int)$product['products_id'] . "'");

    while ($color_id_row = mysql_fetch_array ($color_id_query)) {
    $current_color_id_array[] = $color_id_row['color_id'];
    }
</code></pre>
