Skip to content

Instantly share code, notes, and snippets.

@Daniel15
Last active December 19, 2015 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Daniel15/5991193 to your computer and use it in GitHub Desktop.
Save Daniel15/5991193 to your computer and use it in GitHub Desktop.
The worst possible way I could think of to get the last element of an array in PHP. Obviously don't use this.
<?php
function last($arr)
{
eval('list(' . str_repeat(',', count($arr) - 1) . '$result) = $arr;');
return $result;
}
@DavidGoodwin
Copy link

And for another 'interesting' example, see : https://gist.github.com/palepurple/10023233 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment