ShaolinF Posted November 25, 2009 Share Posted November 25, 2009 Hi Guys I am using the func below to get the last number from the URL. It works, but I want to know if there is a better way to do it: example url: mysite.com/courses/100/ (100 is the post id) //Get the 100 from the URL $current_uri = $_SERVER['REQUEST_URI']; $data = explode("/", $current_uri); $post_id = $data[count($data)-2]; $post_id = filter_var($post_id, FILTER_VALIDATE_INT); echo "The number is" . $post_id; Link to comment https://forums.phpfreaks.com/topic/182952-is-my-code-ok/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.