Advertisement
Guest User

Untitled

a guest
Jul 5th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. $GLOBALS['taskary'] = array(1 => 1,2,3,4,5);
  3.  
  4. echo "12345 - expected" . PHP_EOL;
  5. reset($GLOBALS['taskary']);
  6. while ($next = each($GLOBALS['taskary'])) {
  7.     $val = $next['value'];
  8.     echo $val;
  9.     if ($val == 2) {
  10.         unset($GLOBALS['taskary'][2]);
  11.     }
  12. }
  13. echo PHP_EOL;
  14.  
  15. $GLOBALS['taskary'] = array(1 => 1,2,3,4,5);
  16.  
  17. // ----
  18. echo "1245 - expected" . PHP_EOL;
  19. reset($GLOBALS['taskary']);
  20. while ($next = each($GLOBALS['taskary'])) {
  21.     $val = $next['value'];
  22.     echo $val;
  23.     if ($val == 2) {
  24.         unset($GLOBALS['taskary'][3]);
  25.     }
  26. }
  27. echo PHP_EOL;
  28.  
  29. // ----
  30. $GLOBALS['taskary'] = array(1 => 1,2,3,4,5);
  31. echo "12345 - expected" . PHP_EOL;
  32. reset($GLOBALS['taskary']);
  33. do {
  34.     $val = current($GLOBALS['taskary']);
  35.     echo $val;
  36.     if ($val == 2) {
  37.         unset($GLOBALS['taskary'][2]);
  38.     }
  39.  
  40. } while (next($GLOBALS['taskary']) !== false);
  41. echo PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement