Get the GET variables from a URL String

后端 未结 5 1445
生来不讨喜
生来不讨喜 2020-12-05 11:30

Hey, say I have a url just being passed through my php is there any easy way to get some GET variables that are being passed through it? It\'s not the actual url of the page

5条回答
  •  悲&欢浪女
    2020-12-05 12:25

    I'd use something like:

    preg_match_all('/(\?|&)([^=]+=[^&]*)/', $string , $matches);
    

    then

    print_r($matches[2]);
    /*
    Array
    (
        [0] => url=var
        [1] => file_id=var
        [2] => test=var
    )
    */
    

    Hope it works 4 u.

提交回复
热议问题