Skip to content

Instantly share code, notes, and snippets.

@rightgo09
Created February 3, 2015 02:44
Show Gist options
  • Select an option

  • Save rightgo09/6e6301adc0928cc3f9b4 to your computer and use it in GitHub Desktop.

Select an option

Save rightgo09/6e6301adc0928cc3f9b4 to your computer and use it in GitHub Desktop.
array_shiftした後の配列は添字がちゃんと0から始まる.
<?php
$arr = array(4,1,3);
print_r($arr);
$a = array_shift($arr);
print_r($arr);
array_unshift($arr, $a);
print_r($arr);
//Array
//(
// [0] => 4
// [1] => 1
// [2] => 3
//)
//Array
//(
// [0] => 1
// [1] => 3
//)
//Array
//(
// [0] => 4
// [1] => 1
// [2] => 3
//)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment