Skip to content

Instantly share code, notes, and snippets.

@dduleone
Created December 4, 2014 18:34
Show Gist options
  • Select an option

  • Save dduleone/d34c86b2961ebdf9cf90 to your computer and use it in GitHub Desktop.

Select an option

Save dduleone/d34c86b2961ebdf9cf90 to your computer and use it in GitHub Desktop.
<?php
$sets = array();
$fruit = array('apples', 'grapes');
$numbers = array('one', 'two', 'three');
$sets[] = &$fruit;
$sets[] = &$numbers;
$fruit[] = 'banana';
$numbers[] = 'four';
$sets[] = &$sets[count($sets)-1];
$sets[] = end($sets);
$numbers[] = 'five';
foreach($sets as $set) {
var_dump($set);
}
array(3) {
[0]=>
string(6) "apples"
[1]=>
string(6) "grapes"
[2]=>
string(6) "banana"
}
array(5) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
[2]=>
string(5) "three"
[3]=>
string(4) "four"
[4]=>
string(4) "five"
}
array(5) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
[2]=>
string(5) "three"
[3]=>
string(4) "four"
[4]=>
string(4) "five"
}
array(4) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
[2]=>
string(5) "three"
[3]=>
string(4) "four"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment