Reputation: 81
i kept getting error : Fatal error: Cannot use [] for reading
for($m=1; $m<=12; ++$m){
$monthName=strtolower(date('F', mktime(0, 0, 0, $m, 1)));
<input style='text-align:center' class='form-control ".$monthName."' type='text' size='60' id='".$monthName."' name='".$monthName[]."' value='".$$monthName."'>
}
i want to use array [] for input name..how do i fix this
Upvotes: 0
Views: 439
Reputation: 6006
You combined the square brackets with the php variable, you should add your square brackets externally with the variable as
for($m=1; $m<=12; ++$m){
$monthName=strtolower(date('F', mktime(0, 0, 0, $m, 1)));
<input style='text-align:center' class='form-control ".$monthName."' type='text' size='60' id='".$monthName."' name='".$monthName."[]' value='".$$monthName."'>
}
Upvotes: 2
Reputation: 81
for($m=1; $m<=12; ++$m){
$monthName=strtolower(date('F', mktime(0, 0, 0, $m, 1)));
<input style='text-align:center' class='form-control ".$monthName."' type='text' size='60' id='".$monthName."' name='".$monthName."[]' value='".$$monthName."'>
}
Upvotes: 0