Skip to content

Instantly share code, notes, and snippets.

@masakielastic
Created May 24, 2012 15:17
Show Gist options
  • Save masakielastic/2782167 to your computer and use it in GitHub Desktop.
Save masakielastic/2782167 to your computer and use it in GitHub Desktop.
後入後出 (Last In, Last Out)
> let a = [1, 2, 3]
> last $ a ++ [7]
7
> let b = [3, 4, 5]
> last $ b ++ [6, 9]
9
> let c = [6, 7, 8]
> last $ c ++ [10]
10
<?php
$a = [1, 2, 3];
$a[] = 7;
echo end($a), PHP_EOL; // 7
$b = [3, 4, 5];
array_push($b, 6, 9);
echo end($b), PHP_EOL; // 9
$c = [6, 7, 8];
$c[] = 10;
echo array_pop($c), PHP_EOL; // 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment