Speedysnail6

Array push doesn't work in functions. Even with global

Jun 6th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. ----- The Code -----
  2.  
  3. <?php
  4. $test = array();
  5. function sup() {
  6.     global $test;
  7.     array_push($test, "0");
  8. }
  9. echo "If it works it will say 0 : ";
  10. echo $test[0];
  11. echo "<br>Now we will push again and it will work but its not in a function: ";
  12. array_push($test, "0");
  13. echo $test[0];
  14. ?>
  15.  
  16. ----- The Result -----
  17.  
  18. If it works it will say 0 :
  19. Now we will push again and it will work but its not in a function: 0
Advertisement
Add Comment
Please, Sign In to add comment