Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (range(1,10) as $value) {
- // do something
- }
- function foo() {
- global $counter;
- $counter++;
- return range(1, 10);
- }
- $counter = 0;
- foreach (foo() as $key => $value) {}
- printf("The function was executed %d time(s)n", $counter);
- $counter = 0;
- $result = foo();
- foreach ($result as $key => $value) {}
- printf("The function was executed %d time(s)n", $counter);
- function getrange()
- {
- error_log("running getrange()");
- return range(1,10);
- }
- foreach(getrange() as $val)
- {
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement