Undefined offset
Posted: Sun Sep 25, 2011 5:48 pm
hello!
im trying to get multiple input from checkbox to an array in php, using the following code:
<form...>
<input type="checkbox" name="hobbie[]" value="1">
<input type="checkbox" name="hobbie[]" value="2">
.....
<?php
$hob=array();
$hob=$_POST["hobbie"];
$i=0;
while ($hob[$i])
{
echo $hob[$i];
$i++;
}
?>
im getting the correct values from the hob array, but im getting the: " NOTICE: Undefined offset: 5", where 5 is the length of the array..
why is that? what am i doing wrong???
thanks!!!
im trying to get multiple input from checkbox to an array in php, using the following code:
<form...>
<input type="checkbox" name="hobbie[]" value="1">
<input type="checkbox" name="hobbie[]" value="2">
.....
<?php
$hob=array();
$hob=$_POST["hobbie"];
$i=0;
while ($hob[$i])
{
echo $hob[$i];
$i++;
}
?>
im getting the correct values from the hob array, but im getting the: " NOTICE: Undefined offset: 5", where 5 is the length of the array..
why is that? what am i doing wrong???
thanks!!!