Php Snippet: parse url and separate all it's parts

Php Snippet: parse url and separate all it's parts
by Janeth Kent Date: 11-04-2013

Use this snippet to get some value iside urls, for example the last directory.

$url = 'https://aplicaciones.org/wp-content/uploads/2011/09/skypevideo-500x361.jpg?arg=value#anchor';

print_r(parse_url($url));

$url_path = parse_url($url, PHP_URL_PATH);
$parts = explode('/', $url_path);
$last = end($parts);

echo $last;
 
by Janeth Kent Date: 11-04-2013 hits : 3571  
 
Janeth Kent

Janeth Kent

Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.

 
 
 
Clicky