I have an url stored in a variable such as:
$url = 'example.com?a=20&i=10'
How do I get values stored in variable a
and variable i
? Is there a short way to do this?
I have an url stored in a variable such as:
$url = 'example.com?a=20&i=10'
How do I get values stored in variable a
and variable i
? Is there a short way to do this?
If you want to access those variables, check out the extract() function, it will create variables $a and $i from the parse_str() function above.
However, it will overwrite any existing variable called $a so its to be used with caution.
You could use parse_url and parse_str:
Demo
You can use parse_url().
For more details, refer php manual.
Try this: