0

http://{{base_url}}/post/857161551776694272

I want to get the post_id(which is bold) in the above URL. Parameter does not contain any param name. (Its a PATCH method which also has a json body)

Vihanga Yasith
  • 328
  • 5
  • 18

1 Answers1

0

you can get your url segments with parse_url e.g :

$uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri_segments = explode('/', $uri_path);

echo $uri_segments[0];
echo "<br>";
echo $uri_segments[1];
F. Doe
  • 82
  • 4