i m having multiple choices of colours with checkbox for each color.
i want to check if chosen color value exists in "array" then echo "checked";
<input type="checkbox" name="colors" id="colors" value="red" <? if(in_array('red', $colors)) echo "checked='checked'"; ?> />
This code works fine but at present i have to change the color value in the "in_array" code manually for each color.
so i thought of creating a function which will automatic check for color value existance and then will echo "checked".
but i am stuck in this below function
foreach($chosencolors as $colr)
$cl = $colr ." "; // output as red,yellow
$clr = explode(" ",$cl);
echo $clr; // output as ArrayArray
echo $clr; // output as redyellow
why is $clr giving output as ArrayArray. Its not splitting with explode.
is there any other way of doing the same task.