Two single liners - I suspect that the first one is faster, but the second one is prettier and unlike end() and array_pop() , you can pass the result of the function directly to current() without creating any notifications or warnings, since does not move the pointer or does not change the array.
$var = 'http://www.vimeo.com/1234567'; // VERSION 1 - one liner simmilar to DisgruntledGoat answer above echo substr($a,(strrpos($var,'/') !== false ? strrpos($var,'/') + 1 : 0)); // VERSION 2 - explode, reverse the array, get the first index. echo current(array_reverse(explode('/',$var)));
billynoah Jan 10 '17 at 14:35 2017-01-10 14:35
source share