-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)?

0

1 Answer 1

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
)
Sign up to request clarification or add additional context in comments.

1 Comment

it works , thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.