0

I need to parse through a list of url strings and extract certain parameter values.

These strings are from a database NOT using POST or GET.

Here is an example url string and the goal is to extract the user_id part of the string.

https://www.example.com/?action=get_my_messages&user_id=9825&session_token=1463812ecbfa4

NOTE: the parameter order of the string might be different with different strings and in some cases the user_id might not even exist.

FOUND SOLUTION

$query = parse_url($request_string, PHP_URL_QUERY);
parse_str($query, $params);
$user_id= $params['user_id'];

OBTAINED THE SOLUTION FROM THIS POST BELOW

How do I extract query parameters from a URL string in PHP?

Community
  • 1
  • 1
Craig Edmonds
  • 2,052
  • 3
  • 14
  • 13

0 Answers0