find parameters in url using php

萝らか妹 提交于 2019-12-11 11:41:37

问题


I am searching for a way to find a url that contains a parameter to extract a dynamic value

example, anywhere on my website there is a button with a link that contains characters

example.com/register/register-company.html?tx_powermail_pi1[regUid]=78

i need the id from regUid to work with queries, the 78 is not static.

thx for any help.


回答1:


$str = "http://example.com/somepage?tx_powermail_pi1[regUid]=78";
$uri = parse_url($str);
if($uri["query"]){
   #if there is query string only....
   parse_str($uri["query"], $test);
   var_dump($test);
}

This will work on any url. If you are trying to catch your current url get param you can just use

$_GET['tx_powermail_pi1']['regUid']



来源:https://stackoverflow.com/questions/15875547/find-parameters-in-url-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!