Last active
June 21, 2017 08:49
-
-
Save remcotolsma/abf2c806a39775d70f68673dbebd6b4e 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 | |
$offset = 0; | |
$length = 0; | |
$data = array( | |
'1', | |
'2', | |
'3', | |
'4', | |
'5', | |
'6', | |
); | |
$offset += $length; | |
$length = 3; | |
foreach ( array_slice( $data, $offset, $length ) as $item ) { | |
echo $item, '<br />'; | |
} | |
$offset += $length; | |
$length = 2; | |
foreach ( array_slice( $data, $offset, $length ) as $item ) { | |
echo $item, '<br />'; | |
} | |
$offset += $length; | |
$length = 1; | |
foreach ( array_slice( $data, $offset, $length ) as $item ) { | |
echo $item, '<br />'; | |
} | |
$offset += $length; | |
$length = null; | |
foreach ( array_slice( $data, $offset, $length ) as $item ) { | |
echo $item, '<br />'; | |
} |
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( | |
'1', | |
'2', | |
'3', | |
'4', | |
'5', | |
'6', | |
); | |
$item = reset( $data ); | |
foreach ( range( 1, 2 ) as $i ) { | |
echo $item, '<br />'; | |
$item = next( $data ); | |
} | |
foreach ( range( 1, 3 ) as $i ) { | |
echo $item, '<br />'; | |
$item = next( $data ); | |
} | |
echo $item, '<br />'; | |
$item = next( $data ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment