hi all
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";
This code works fine but at present i have to change the color value in the "in_array" code manually for each color.PHP Code:<input type="checkbox" name="colors[]" id="colors[]" value="red" <? if(in_array('red', $colors)) echo "checked='checked'"; ?> />
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
why is $clr giving output as ArrayArray. Its not splitting with explode.PHP Code:$chosencolors=array("red","yellow");
foreach($chosencolors as $colr)
{
$cl = $colr ." "; // output as red,yellow
$clr = explode(" ",$cl);
echo $clr; // output as ArrayArray
echo $clr[0]; // output as redyellow
}
is there any other way of doing the same task.
vineet



Reply With Quote



Bookmarks