Is there a built-in function that gets the last element of a php array that doesn't require it to be referenced from a variable? end()
and array_pop()
work, but throw a notice
.
What I have:
$example_url = '/demo/site/site.cfg';
$explosion = explode('/', $example_url);
if (end($explosion) == 'site.cfg') {
//...
}
This throws Notice: Only variables should be passed by reference
:
$example_url = '/demo/site/site.cfg';
if (end(explode('/', $example_url)) == 'site.cfg') {
//...
}