Multiple HTTP GET parameters with the same identifier

前端 未结 5 798
孤独总比滥情好
孤独总比滥情好 2020-12-03 14:47

Let\'s say I am getting requests such as:

http://www.example.com/index.php?id=123&version=3&id=234&version=4

Is it possible to extra

5条回答
  •  伪装坚强ぢ
    2020-12-03 15:34

    Not as rounded or reliable as methods mentioned above but I use this to remove the need to [] in urls without worrying about rewriting.

    $aQuery = explode("&", $_SERVER['QUERY_STRING']);
    $aQueryOutput = array();
    foreach ($aQuery as $param) {
        if(!empty($param)){
            $aTemp = explode('=', $param, 2);
            if(isset($aTemp[1]) && $aTemp[1] !== ""){
                list($name, $value) = explode('=', $param, 2);
                $aQueryOutput[ strtolower(urldecode($name)) ][] = urldecode(preg_replace('/[^a-z 0-9\'+-]/i', "", $value));
            }
        }
    }
    

提交回复
热议问题