This function works perfectly if the while condition is ($q > 1) but it gets a "Error 500 - Internal server error" if the condition is ($q > 2) or higher than 3. Why is this happening? I can't work it out. 
The function takes an array such as array('box', 'item') and then searches to see if there is post variables such as:
box_0:item_0
box_0:item_1
box_0:item_2
box_1:item_0
box_1:item_1
box_2:item_0
box_2:item_0
and then returns an array that looks like this array('box0:item', 'box1:item', 'box2:item')
It doesn't really matter what the function is achieving exactly, I just don't understand why I get the error after so few iterations. 
PHP Code:
function ConstructPostArray($variable_parts_array) {
$o = count($variable_parts_array);
$q = 0;
for ($i = 0; $i < ($o - 1); ++$i) {
$array_level[$i] = 0;
}
$last = ($i - 1);
while ($q < 3) {
for ($i = 0, $postname=''; $i < $o; ++$i) {
if (($i + 1) < $o) {
$postname .= $variable_parts_array[$i] . '_' . $array_level[$i] . ':';
} else {
$postname .= $variable_parts_array[$i];
}
}
if (isset($_POST[$postname . '_0'])) {
$postname_array[$q] = $postname;
++$array_level[$last];
++$q;
}
}
return $postname_array;
}
Any help would be much appreciated
Thank you, ro0bear
Bookmarks