复选框返回最后一个值

I´m trying to do a checkbox in my form but its just returning the last value. What´s wrong here?

if ($type == "w") {
    //check buttons
    foreach ($values as $indexa => $value) {
        $value = trim($value);
        echo "<input type=\"checkbox\" name=\"input[$fieldno]\"  value=\"$value\" ";                   
        if (isset($input)) {
            if ($input[$fieldno] == $value) {
                echo " checked";
      // var_dump($fieldno); die();
            }
        }
        if ($compulsory == 1) {
            echo " class=\"required\"";
        }
        $label = ($value == 'OTHER') ? 'OUTROS' : $value;
        echo " onclick=radio_other($fieldno,\"$value\")> $label<br>";
    }
    if (strtoupper($value) == "OTHER") {
        echo "<input type=\"text\" name=\"other[$fieldno]\" id=\"other[$fieldno]\" style=\"display:none\">";
    }
}

Ps: $type == w is a checkbox type.