I have simple PHP array with data from checkbox. I need add values into array and then insert data into database. It works but foreach not infringement parameter.
So i testing with increment:
$arr = array();
array_push($arr, $_POST['chbox']);
and it looks like 123,125 in array (two elements)
Next step is to return number of elements (or values in next step):
$id=0;
foreach( $arr as $row)
{
$id++;
};
and returns $id=1;
if i'm trying read values:
foreach( $arr as $row)
{
$row[$id]
$id++;
};
Return only 123
$arr = $_POST['chbox'];$row[$id]returns that? There is noecho. Also, if you just want to turn string keys to numeric, take a look at array_values.array_push, do avar_dump($arr);- what do you get? Then a foreach should be simple:foreach($arr AS $i => $row) {echo $row[$i];}. NOTE - if the$_POSTis a checkbox, AND the checkbox is NOT checked, then that$_POSTkey will be EMPTY, and will not actually return anything.count($arr)