<?php
$GLOBALS['taskary'] = array(
	"1" => 1,
	"2" => 2,
	"3" => 3,
	"4" => 4,

);

echo "should print 1234" . PHP_EOL;
reset($GLOBALS['taskary']);
while ($next = each($GLOBALS['taskary'])) {
	$val = $next['value'];
	echo $val;
	if ($val == 2) {
		// Remove the current array element
		unset($GLOBALS['taskary'][2]);
	}
} 
echo PHP_EOL;

$GLOBALS['taskary'] = array(
	"1" => 1,
	"2" => 2,
	"3" => 3,
	"4" => 4,
	"5" => 5,

);

echo "should print 1245 - correctly, since 3 was removed" . PHP_EOL;
reset($GLOBALS['taskary']);
while ($next = each($GLOBALS['taskary'])) {
	$val = $next['value'];
	echo $val;
	if ($val == 2) {
		// Remove the next array element
		unset($GLOBALS['taskary'][3]);
	}
} 
echo PHP_EOL;

$GLOBALS['taskary'] = array(
	"1" => 1,
	"2" => 2,
	"3" => 3,
	"4" => 4,

);

echo "should print 1234 - incorrectly prints 124 (skipping 3)" . PHP_EOL;
reset($GLOBALS['taskary']);
do {
	$val = current($GLOBALS['taskary']);
	echo $val;
	if ($val == 2) {
		unset($GLOBALS['taskary'][2]);
	}

} while (next($GLOBALS['taskary']) !== false);
echo PHP_EOL;
