I'm using webforms to get some data from users. These results are later used in another php script, and this relies on looping through the data:
for ($i = 1; $i <= count($data); $i++)
{
$answers[] = $data[$i]["value"][0];
}
However, by adding and deleting questions in the webform, the indices look something like this now:
1
2
3
5
8
12
And this gives an error because I use count()
to get the number of entries. (count() = 6
, but max() = 12
). My first idea is to find a way to automatically reset the indices after adding or removing questions. So my indices look like this:
1
2
3
4
5
6
But I honestly have no idea how to go about this. Any ideas?