Skip to content

Instantly share code, notes, and snippets.

@littlefuntik
Created November 17, 2016 07:42
Show Gist options
  • Save littlefuntik/c148539ef7b83c808de5f5a5f1b04c35 to your computer and use it in GitHub Desktop.
Save littlefuntik/c148539ef7b83c808de5f5a5f1b04c35 to your computer and use it in GitHub Desktop.
<?php
$array = new SplFixedArray(2);
$array[0] = 'A';
$array[1] = 'B';
$offset = 0;
if ($array->offsetExists($offset)) {
$sizeNew = $array->getSize() - 1;
for ($i = $offset; $i < $sizeNew; ++$i) {
$array[$offset] = $array[$offset + 1];
}
$array->setSize($sizeNew);
}
var_dump($array->toArray());
/**
array(1) {
[0] =>
string(1) "B"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment