-1

I have a URL like so:

http://example.com/var1/var2

What I'd like to is get VAR 1 from the querystring. I've tried using a regex but I'm not really very familiar with them. Is there an easier way?

Kev
  • 143
  • 1
  • 1
  • 8

1 Answers1

0

Another approach

<?php
$e = explode("/",parse_url("http://example.com/a/b")["path"])[1];
// $e now is "a"
ShiSHcat
  • 83
  • 1
  • 8