Pick up the last explode position

2

I need to get the last position after giving explode . How do I?

 $geturl = explode('/', $_SERVER['REQUEST_URI']);

 self::$modulo = isset($geturl[2]) ? $geturl[2] : '';
 self::$funcao = isset($geturl[3]) ? $geturl[3] : '';
 self::$chave = isset($geturl[4]) ? $geturl[4] : '';

Note: It may happen that% of% is null

    
asked by anonymous 02.05.2017 / 21:52

1 answer

6

Use the end() function to leave the array pointer in the last position and get its value.

$ultimo = end($geturl);
    
02.05.2017 / 21:53