-1

with the URL

domain.com/index.php?option=component&ctrl=product&task=show&cid=5076

$parse = parse_url( $full_url, PHP_URL_QUERY);
echo $parse['ctrl']; // I get nothing

How can I get my values from keys (option, ctrl, task, and cid)?

Rahul
  • 18,271
  • 7
  • 41
  • 60
Erick Boileau
  • 478
  • 4
  • 14

1 Answers1

2

You can use parse_str along with parse_url,

$full_url = "domain.com/index.php?option=component&ctrl=product&task=show&cid=5076";
parse_str(parse_url($full_url,PHP_URL_QUERY), $arr); // parse query string
print_r($arr);

Demo

Output

Array
(
    [option] => component
    [ctrl] => product
    [task] => show
    [cid] => 5076
)
Rahul
  • 18,271
  • 7
  • 41
  • 60