I have a snippet of PHP code, it works but I was curious to know why.
Green: <input type="checkbox" name="color[]" value="green" />
Black: <input type="checkbox" name="color[]" value="black" />
White: <input type="checkbox" name="color[]" value="white" />
Blue: <input type="checkbox" name="color[]" value="blue" />
Red: <input type="checkbox" name="color[]" value="red" />
then here is what I don't get for this PHP code below, how is $colors an array, I thought you have to at least have $colors[] = $_POST['color'].
if (isset($_POST['color'])) {
$colors = $_POST['color'];
}
echo $colors[0];
Thanks for helping me better understand this.