Skip to content

Instantly share code, notes, and snippets.

@blogcacanid
Created April 16, 2020 10:25
Show Gist options
  • Save blogcacanid/4c61c52d8fdc1560762500df6a64baa3 to your computer and use it in GitHub Desktop.
Save blogcacanid/4c61c52d8fdc1560762500df6a64baa3 to your computer and use it in GitHub Desktop.
get_uri Covid-19 AngularJS
<?php
// Get URI Segments
$uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
// Usage:
// URL = http://www.example.com/codex/foo/bar.
//echo $uriSegments[1]; //returns codex
//echo $uriSegments[2]; //returns foo
//echo $uriSegments[3]; //returns bar
// Get Last URL Segment
$lastUriSegment = array_pop($uriSegments);
// Usage:
// URL = http://www.example.com/codex/foo/bar.
//$lastUriSegment = array_pop($uriSegments);
//echo $lastUriSegment; //returns bar
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment