Created
July 28, 2011 15:38
-
-
Save caefer/1111774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = array(/*..some huge array..*/); | |
| do { | |
| $current = current($data); | |
| $key = key($data); | |
| $next = next($data); | |
| /*..some action..*/ | |
| if (/*..some condition.. */) { | |
| // add something to the array after the current position | |
| array_splice($data, $key, 0, /*..some payload.. */); | |
| // skip the payload we just added | |
| $next = next($data); | |
| /** | |
| * unfortunately array_splice() reset the array.. | |
| * so the pointer is now pointing to the second element.. | |
| */ | |
| } | |
| } while ($next); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment