I have used Multiple select Box in edit form, displaying previously selected items in it using "in-array($needle,$haystack)" php function, but if the variable array "$haystack" in which multiple value is stored, there is no value,there I get the Warning message prompting for wrong datatype for second argument for in "in-array($needle,$haystack)"
My Select box code goes like this:
**<select name="otherdiseases[]" id="otherdiseases" class="list-menu" multiple="multiple">
<option value=''>Other Medical Diseases</option>
<option value='Prior heart Attack'<?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Prior heart Attack',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?>>Prior heart Attack</option>
<option value='Ischemic Heart Attack'<?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Ischemic Heart Attack',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }else{ ?> selected=""<?php }?>>Ischemic Heart Attack</option>
<option value='Stroke' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Stroke',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >Stroke</option>
<option value='Dialysis' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Dialysis',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >Dialysis</option>
<option value='High BP' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('High BP',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >High BP</option>
<option value='High Cholesterol' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('High Cholesterol',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >High Cholesterol</option>
<option value='Thyroid' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Thyroid',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >Thyroid</option>
<option value='Previous Eye Laser Therapy' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Previous Eye Laser Therapy',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >Previous Eye Laser Therapy</option>
<option value='Foot Surgeries' <?php if(count($res_user[0]['otherdiseases'])!=0){ if(in_array('Foot Surgeries',$res_user[0]['otherdiseases'])){ ?> selected="selected" <?php } }?> >Foot Surgeries</option>
</select>**
In above code the variable array $res_user[0]['otherdiseases'] is extracted from a select query, which I have already cross checked using var_dump, for its value presence...
Please Help me out to rectify me the situation when there is 0 value in $res_user[0]['otherdiseases'].. to avoid the above mention warning...